protected function HelpTopicPluginManager::findDefinitions in Drupal 8
Same name and namespace in other branches
- 9 core/modules/help_topics/src/HelpTopicPluginManager.php \Drupal\help_topics\HelpTopicPluginManager::findDefinitions()
Finds plugin definitions.
Return value
array List of definitions to store in cache.
Overrides DefaultPluginManager::findDefinitions
File
- core/
modules/ help_topics/ src/ HelpTopicPluginManager.php, line 165
Class
- HelpTopicPluginManager
- Provides the default help_topic manager.
Namespace
Drupal\help_topicsCode
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;
}