function HelpTopicPluginManager::getDiscovery

Same name in other branches
  1. 8.9.x core/modules/help_topics/src/HelpTopicPluginManager.php \Drupal\help_topics\HelpTopicPluginManager::getDiscovery()
  2. 10 core/modules/help/src/HelpTopicPluginManager.php \Drupal\help\HelpTopicPluginManager::getDiscovery()
  3. 11.x core/modules/help/src/HelpTopicPluginManager.php \Drupal\help\HelpTopicPluginManager::getDiscovery()

Overrides DefaultPluginManager::getDiscovery

File

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

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;
}

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