public function LanguageHierarchyConfigFactoryOverride::loadOverrides in Language Hierarchy 2.x
Same name and namespace in other branches
- 8 src/Config/LanguageHierarchyConfigFactoryOverride.php \Drupal\language_hierarchy\Config\LanguageHierarchyConfigFactoryOverride::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 LanguageConfigFactoryOverride::loadOverrides
File
- src/
Config/ LanguageHierarchyConfigFactoryOverride.php, line 23
Class
- LanguageHierarchyConfigFactoryOverride
- Provides language overrides for the configuration factory, with fallbacks.
Namespace
Drupal\language_hierarchy\ConfigCode
public function loadOverrides($names) {
// Skip to using the parent implementation if there is no fallback chain or
// language. If the fallback chain just hasn't been computed yet, read it
// directly from base storage to avoid a circular dependency on the
// configuration factory.
if ($this->language && (!isset($this->fallbackChain) || !empty($this->fallbackChain))) {
$storage = $this
->getStorage($this->language
->getId());
$loaded = $storage
->readMultiple($names);
if ($missing = array_diff($names, array_keys($loaded))) {
// Try fallback languages.
if (!isset($this->fallbackChain)) {
$this->fallbackChain = $this
->getFallbackChainFromBaseConfig($this->language
->getId());
}
$ancestors = $this->fallbackChain;
while ($missing && ($ancestor = array_shift($ancestors))) {
$fallback_storage = $this
->getStorage($ancestor);
$loaded += $fallback_storage
->readMultiple($missing);
$missing = array_diff($names, array_keys($loaded));
}
}
return $loaded;
}
else {
return parent::loadOverrides($names);
}
}