protected function LanguageHierarchyConfigFactoryOverride::getFallbackChainFromBaseConfig in Language Hierarchy 8
Same name and namespace in other branches
- 2.x src/Config/LanguageHierarchyConfigFactoryOverride.php \Drupal\language_hierarchy\Config\LanguageHierarchyConfigFactoryOverride::getFallbackChainFromBaseConfig()
Compute the fallback chain for a language code.
Before the config factory is available for us to use to get proper language configuration entities, the base storage and raw configuration values have to be used directly to compute the fallback chain.
1 call to LanguageHierarchyConfigFactoryOverride::getFallbackChainFromBaseConfig()
- LanguageHierarchyConfigFactoryOverride::loadOverrides in src/
Config/ LanguageHierarchyConfigFactoryOverride.php - Returns config overrides.
File
- src/
Config/ LanguageHierarchyConfigFactoryOverride.php, line 106
Class
- LanguageHierarchyConfigFactoryOverride
- Provides language overrides for the configuration factory, with fallbacks.
Namespace
Drupal\language_hierarchy\ConfigCode
protected function getFallbackChainFromBaseConfig($langcode) {
// The config prefix here has to be hardcoded because it would come from the
// entity type definition, but the entity type manager cannot return that
// yet as that indirectly depends on this config factory override service.
$language_config = $this->baseStorage
->read('language.entity.' . $langcode);
$fallbacks = [];
while (!empty($language_config['third_party_settings']['language_hierarchy']['fallback_langcode'])) {
$ancestor_langcode = $language_config['third_party_settings']['language_hierarchy']['fallback_langcode'];
// Protect against infinite recursion due to unexpected configuration.
if (in_array($ancestor_langcode, $fallbacks, TRUE)) {
break;
}
else {
$fallbacks[] = $ancestor_langcode;
$language_config = $this->baseStorage
->read('language.entity.' . $ancestor_langcode);
}
}
return $fallbacks;
}