You are here

public function PirateDayCacheabilityMetadataConfigOverride::loadOverrides in Drupal 10

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

File

core/modules/config/tests/config_override_test/src/PirateDayCacheabilityMetadataConfigOverride.php, line 18

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