function ConfigMapperManager::getDiscovery

Same name in other branches
  1. 9 core/modules/config_translation/src/ConfigMapperManager.php \Drupal\config_translation\ConfigMapperManager::getDiscovery()
  2. 8.9.x core/modules/config_translation/src/ConfigMapperManager.php \Drupal\config_translation\ConfigMapperManager::getDiscovery()
  3. 10 core/modules/config_translation/src/ConfigMapperManager.php \Drupal\config_translation\ConfigMapperManager::getDiscovery()

Overrides DefaultPluginManager::getDiscovery

File

core/modules/config_translation/src/ConfigMapperManager.php, line 89

Class

ConfigMapperManager
Manages plugins for configuration translation mappers.

Namespace

Drupal\config_translation

Code

protected function getDiscovery() {
    if (!isset($this->discovery)) {
        // Look at all themes and modules.
        // @todo If the list of installed modules and themes is changed, new
        //   definitions are not picked up immediately and obsolete definitions
        //   are not removed, because the list of search directories is only
        //   compiled once in this constructor. The current code only works due to
        //   coincidence: The request that installs (for instance, a new theme)
        //   does not instantiate this plugin manager at the beginning of the
        //   request; when routes are being rebuilt at the end of the request,
        //   this service only happens to get instantiated with the updated list
        //   of installed themes.
        $directories = [];
        foreach ($this->moduleHandler
            ->getModuleList() as $name => $module) {
            $directories[$name] = $module->getPath();
        }
        foreach ($this->themeHandler
            ->listInfo() as $theme) {
            $directories[$theme->getName()] = $theme->getPath();
        }
        // Check for files named MODULE.config_translation.yml and
        // THEME.config_translation.yml in module/theme roots.
        $this->discovery = new YamlDiscovery('config_translation', $directories);
        $this->discovery = new InfoHookDecorator($this->discovery, 'config_translation_info');
        $this->discovery = new ContainerDerivativeDiscoveryDecorator($this->discovery);
    }
    return $this->discovery;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.