You are here

protected function HelpTopicPluginManager::getDiscovery in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/help_topics/src/HelpTopicPluginManager.php \Drupal\help_topics\HelpTopicPluginManager::getDiscovery()

Gets the plugin discovery.

Return value

\Drupal\Component\Plugin\Discovery\DiscoveryInterface

Overrides DefaultPluginManager::getDiscovery

File

core/modules/help_topics/src/HelpTopicPluginManager.php, line 130

Class

HelpTopicPluginManager
Provides the default help_topic manager.

Namespace

Drupal\help_topics

Code

protected function getDiscovery() {
  if (!isset($this->discovery)) {
    $module_directories = $this->moduleHandler
      ->getModuleDirectories();
    $all_directories = array_merge([
      'core' => $this->root . '/core',
    ], $module_directories, $this->themeHandler
      ->getThemeDirectories());

    // Search for Twig help topics in subdirectory help_topics, under
    // modules/profiles, themes, and the core directory.
    $all_directories = array_map(function ($dir) {
      return [
        $dir . '/help_topics',
      ];
    }, $all_directories);
    $discovery = new HelpTopicDiscovery($all_directories);

    // Also allow modules/profiles to extend help topic discovery to their
    // own plugins and derivers, in mymodule.help_topics.yml files.
    $discovery = new YamlDiscoveryDecorator($discovery, 'help_topics', $module_directories);
    $discovery = new ContainerDerivativeDiscoveryDecorator($discovery);
    $this->discovery = $discovery;
  }
  return $this->discovery;
}