Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 8 |
ThemeCacheContext | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 8 |
__construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
getLabel | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
getContext | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 2 |
|||
getCacheableMetadata | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
<?php | |
/** | |
* @file | |
* Contains \Drupal\Core\Cache\Context\ThemeCacheContext. | |
*/ | |
namespace Drupal\Core\Cache\Context; | |
use Drupal\Core\Cache\CacheableMetadata; | |
use Drupal\Core\Theme\ThemeManagerInterface; | |
/** | |
* Defines the ThemeCacheContext service, for "per theme" caching. | |
* | |
* Cache context ID: 'theme'. | |
*/ | |
class ThemeCacheContext implements CacheContextInterface { | |
/** | |
* The theme manager. | |
* | |
* @var \Drupal\Core\Theme\ThemeManagerInterface | |
*/ | |
protected $themeManager; | |
/** | |
* Constructs a new ThemeCacheContext service. | |
* | |
* @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager | |
* The theme manager. | |
*/ | |
public function __construct(ThemeManagerInterface $theme_manager) { | |
$this->themeManager = $theme_manager; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public static function getLabel() { | |
return t('Theme'); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getContext() { | |
return $this->themeManager->getActiveTheme()->getName() ?: 'stark'; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getCacheableMetadata() { | |
return new CacheableMetadata(); | |
} | |
} |