You are here

protected function LanguageHierarchyConfigFactoryOverride::getFallbackChainFromConfigEntities in Language Hierarchy 8

Same name and namespace in other branches
  1. 2.x src/Config/LanguageHierarchyConfigFactoryOverride.php \Drupal\language_hierarchy\Config\LanguageHierarchyConfigFactoryOverride::getFallbackChainFromConfigEntities()

Compute the fallback chain for a language code.

The entity type manager and language configuration entities should be available by the time this is needed, as language overrides are loaded during the Kernel request event. We cannot inject the entity type manager as a dependency because that would create a circular dependency.

See also

\Drupal\language\EventSubscriber\LanguageRequestSubscriber::getSubscribedEvents()

2 calls to LanguageHierarchyConfigFactoryOverride::getFallbackChainFromConfigEntities()
LanguageHierarchyConfigFactoryOverride::getOverride in src/Config/LanguageHierarchyConfigFactoryOverride.php
Get language override for given language and configuration name.
LanguageHierarchyConfigFactoryOverride::setLanguage in src/Config/LanguageHierarchyConfigFactoryOverride.php
Sets the language to be used in configuration overrides.

File

src/Config/LanguageHierarchyConfigFactoryOverride.php, line 139

Class

LanguageHierarchyConfigFactoryOverride
Provides language overrides for the configuration factory, with fallbacks.

Namespace

Drupal\language_hierarchy\Config

Code

protected function getFallbackChainFromConfigEntities($langcode) {

  /** @var \Drupal\language\ConfigurableLanguageInterface $language_config */
  $language_config = \Drupal::entityTypeManager()
    ->getStorage('configurable_language')
    ->load($langcode);
  $fallbacks = language_hierarchy_get_ancestors($language_config);
  return array_keys($fallbacks);
}