3 namespace Drupal\Core\Config;
5 use Drupal\Component\Utility\NestedArray;
6 use Drupal\Core\Language\LanguageInterface;
7 use Symfony\Component\EventDispatcher\Event;
10 * Event object to allow configuration to be overridden by modules.
12 class ConfigModuleOverridesEvent extends Event {
15 * Configuration names.
22 * Configuration overrides.
29 * The Language object used to override configuration data.
31 * @var \Drupal\Core\Language\LanguageInterface
36 * Constructs a configuration overrides event object.
39 * A list of configuration names.
40 * @param \Drupal\Core\Language\LanguageInterface $language
41 * (optional) The language for this configuration.
43 public function __construct(array $names, LanguageInterface $language = NULL) {
44 $this->names = $names;
45 $this->language = $language;
46 $this->overrides = [];
50 * Gets configuration names.
53 * The list of configuration names that can be overridden.
55 public function getNames() {
60 * Gets configuration language.
62 * @return \Drupal\Core\Language\LanguageInterface
63 * The configuration language object.
65 public function getLanguage() {
66 return $this->language;
70 * Get configuration overrides.
73 * The array of configuration overrides.
75 public function getOverrides() {
76 return $this->overrides;
80 * Sets a configuration override for the given name.
83 * The configuration object name to override.
84 * @param array $values
85 * The values in the configuration object to override.
89 public function setOverride($name, array $values) {
90 if (in_array($name, $this->names)) {
91 if (isset($this->overrides[$name])) {
92 // Existing overrides take precedence since these will have been added
93 // by events with a higher priority.
94 $this->overrides[$name] = NestedArray::mergeDeepArray([$values, $this->overrides[$name]], TRUE);
97 $this->overrides[$name] = $values;