class PirateDayCacheabilityMetadataConfigOverride
Same name in other branches
- 9 core/modules/config/tests/config_override_test/src/PirateDayCacheabilityMetadataConfigOverride.php \Drupal\config_override_test\PirateDayCacheabilityMetadataConfigOverride
- 8.9.x core/modules/config/tests/config_override_test/src/PirateDayCacheabilityMetadataConfigOverride.php \Drupal\config_override_test\PirateDayCacheabilityMetadataConfigOverride
- 11.x core/modules/config/tests/config_override_test/src/PirateDayCacheabilityMetadataConfigOverride.php \Drupal\config_override_test\PirateDayCacheabilityMetadataConfigOverride
Test implementation of a config override that provides cacheability metadata.
Hierarchy
- class \Drupal\config_override_test\PirateDayCacheabilityMetadataConfigOverride implements \Drupal\Core\Config\ConfigFactoryOverrideInterface
Expanded class hierarchy of PirateDayCacheabilityMetadataConfigOverride
1 string reference to 'PirateDayCacheabilityMetadataConfigOverride'
- config_override_test.services.yml in core/
modules/ config/ tests/ config_override_test/ config_override_test.services.yml - core/modules/config/tests/config_override_test/config_override_test.services.yml
1 service uses PirateDayCacheabilityMetadataConfigOverride
- config_override_test.pirate_day_cacheability_metadata_override in core/
modules/ config/ tests/ config_override_test/ config_override_test.services.yml - Drupal\config_override_test\PirateDayCacheabilityMetadataConfigOverride
File
-
core/
modules/ config/ tests/ config_override_test/ src/ PirateDayCacheabilityMetadataConfigOverride.php, line 13
Namespace
Drupal\config_override_testView source
class PirateDayCacheabilityMetadataConfigOverride implements ConfigFactoryOverrideInterface {
/**
* {@inheritdoc}
*/
public function loadOverrides($names) {
$overrides = [];
// Override the theme and the 'call_to_action' block on Pirate Day.
if (PirateDayCacheContext::isPirateDay()) {
if (in_array('system.theme', $names)) {
$overrides = $overrides + [
'system.theme' => [
'default' => 'pirate',
],
];
}
if (in_array('block.block.call_to_action', $names)) {
$overrides = $overrides + [
'block.block.call_to_action' => [
'settings' => [
'label' => 'Draw yer cutlasses!',
],
],
];
}
}
return $overrides;
}
/**
* {@inheritdoc}
*/
public function getCacheSuffix() {
return 'PirateDayConfigOverrider';
}
/**
* {@inheritdoc}
*/
public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) {
return NULL;
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata($name) {
$metadata = new CacheableMetadata();
$metadata->setCacheContexts([
'pirate_day',
])
->setCacheTags([
'pirate-day-tag',
])
->setCacheMaxAge(PirateDayCacheContext::PIRATE_DAY_MAX_AGE);
return $metadata;
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.