You are here

protected function ConfigMapperManager::getDiscovery in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config_translation/src/ConfigMapperManager.php \Drupal\config_translation\ConfigMapperManager::getDiscovery()

Gets the plugin discovery.

Return value

\Drupal\Component\Plugin\Discovery\DiscoveryInterface

Overrides DefaultPluginManager::getDiscovery

File

core/modules/config_translation/src/ConfigMapperManager.php, line 86
Contains \Drupal\config_translation\ConfigMapperManager.

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 e.g. 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 = array();
    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;
}