ConfigMapperManager::getDiscovery

protected 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 81

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 = 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;
}
doc_Drupal
2016-10-29 08:54:11
Comments
Leave a Comment

Please login to continue.