Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 23 |
| CacheabilityMetadataConfigOverride | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
56 | |
0.00% |
0 / 23 |
| loadOverrides | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 11 |
|||
| getCacheSuffix | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| createConfigObject | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getCacheableMetadata | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 8 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\config_override_integration_test\CacheabilityMetadataConfigOverride. | |
| */ | |
| namespace Drupal\config_override_integration_test; | |
| use Drupal\Core\Cache\CacheableMetadata; | |
| use Drupal\Core\Config\ConfigFactoryOverrideInterface; | |
| use Drupal\Core\Config\StorageInterface; | |
| /** | |
| * Test implementation of a config override that provides cacheability metadata. | |
| */ | |
| class CacheabilityMetadataConfigOverride implements ConfigFactoryOverrideInterface { | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function loadOverrides($names) { | |
| $overrides = []; | |
| // Override the test block depending on the state set in the test. | |
| $state = \Drupal::state()->get('config_override_integration_test.enabled', FALSE); | |
| if (in_array('block.block.config_override_test', $names) && $state !== FALSE) { | |
| $overrides = $overrides + [ | |
| 'block.block.config_override_test' => [ | |
| 'settings' => ['label' => 'Overridden block label'], | |
| ], | |
| ]; | |
| } | |
| return $overrides; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function getCacheSuffix() { | |
| return 'config_override_integration_test'; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) { | |
| return NULL; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function getCacheableMetadata($name) { | |
| $metadata = new CacheableMetadata(); | |
| if ($name === 'block.block.config_override_test') { | |
| $metadata | |
| ->setCacheContexts(['config_override_integration_test']) | |
| ->setCacheTags(['config_override_integration_test_tag']); | |
| } | |
| return $metadata; | |
| } | |
| } |