function PirateDayCacheabilityMetadataConfigOverride::loadOverrides

Same name in other branches
  1. 9 core/modules/config/tests/config_override_test/src/PirateDayCacheabilityMetadataConfigOverride.php \Drupal\config_override_test\PirateDayCacheabilityMetadataConfigOverride::loadOverrides()
  2. 8.9.x core/modules/config/tests/config_override_test/src/PirateDayCacheabilityMetadataConfigOverride.php \Drupal\config_override_test\PirateDayCacheabilityMetadataConfigOverride::loadOverrides()
  3. 11.x 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.