You are here

public function ConfigModuleOverridesEvent::setOverride in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php \Drupal\Core\Config\ConfigModuleOverridesEvent::setOverride()

Sets a configuration override for the given name.

Parameters

string $name: The configuration object name to override.

array $values: The values in the configuration object to override.

Return value

$this

File

core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php, line 89

Class

ConfigModuleOverridesEvent
Event object to allow configuration to be overridden by modules.

Namespace

Drupal\Core\Config

Code

public function setOverride($name, array $values) {
  if (in_array($name, $this->names)) {
    if (isset($this->overrides[$name])) {

      // Existing overrides take precedence since these will have been added
      // by events with a higher priority.
      $this->overrides[$name] = NestedArray::mergeDeepArray([
        $values,
        $this->overrides[$name],
      ], TRUE);
    }
    else {
      $this->overrides[$name] = $values;
    }
  }
  return $this;
}