function HelpTopicPluginManager::findDefinitions

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

Overrides DefaultPluginManager::findDefinitions

File

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

Class

HelpTopicPluginManager
Provides the default help_topic manager.

Namespace

Drupal\help_topics

Code

protected function findDefinitions() {
    $definitions = parent::findDefinitions();
    // At this point the plugin list only contains valid plugins. Ensure all
    // related plugins exist and the relationship is bi-directional. This
    // ensures topics are listed on their related topics.
    foreach ($definitions as $plugin_id => $plugin_definition) {
        foreach ($plugin_definition['related'] as $key => $related_id) {
            // If the related help topic does not exist it might be for a module
            // that is not installed. Remove it.
            // @todo Discuss this more as this could cause silent errors but it
            //   offers useful functionality to relate to help topic provided by
            //   extensions that are yet to be installed.
            if (!isset($definitions[$related_id])) {
                unset($definitions[$plugin_id]['related'][$key]);
                continue;
            }
            // Make the related relationship bi-directional.
            if (isset($definitions[$related_id]) && !in_array($plugin_id, $definitions[$related_id]['related'], TRUE)) {
                $definitions[$related_id]['related'][] = $plugin_id;
            }
        }
    }
    return $definitions;
}

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