You are here

public function PirateDayCacheabilityMetadataConfigOverride::loadOverrides in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config/tests/config_override_test/src/PirateDayCacheabilityMetadataConfigOverride.php \Drupal\config_override_test\PirateDayCacheabilityMetadataConfigOverride::loadOverrides()

Returns config overrides.

Parameters

array $names: A list of configuration names that are being loaded.

Return value

array An array keyed by configuration name of override data. Override data contains a nested array structure of overrides.

Overrides ConfigFactoryOverrideInterface::loadOverrides

File

core/modules/config/tests/config_override_test/src/PirateDayCacheabilityMetadataConfigOverride.php, line 23
Contains \Drupal\config_override_test\PirateDayCacheabilityMetadataConfigOverride.

Class

PirateDayCacheabilityMetadataConfigOverride
Test implementation of a config override that provides cacheability metadata.

Namespace

Drupal\config_override_test

Code

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;
}