function HelpTopicSection::getPlugins
Same name in other branches
- 9 core/modules/help_topics/src/Plugin/HelpSection/HelpTopicSection.php \Drupal\help_topics\Plugin\HelpSection\HelpTopicSection::getPlugins()
- 8.9.x core/modules/help_topics/src/Plugin/HelpSection/HelpTopicSection.php \Drupal\help_topics\Plugin\HelpSection\HelpTopicSection::getPlugins()
- 10 core/modules/help/src/Plugin/HelpSection/HelpTopicSection.php \Drupal\help\Plugin\HelpSection\HelpTopicSection::getPlugins()
Gets the top level help topic plugins.
Return value
\Drupal\help\HelpTopicPluginInterface[] The top level help topic plugins.
2 calls to HelpTopicSection::getPlugins()
- HelpTopicSection::getCacheMetadata in core/
modules/ help/ src/ Plugin/ HelpSection/ HelpTopicSection.php - Gets the merged CacheableMetadata for all the top level help topic plugins.
- HelpTopicSection::listTopics in core/
modules/ help/ src/ Plugin/ HelpSection/ HelpTopicSection.php
File
-
core/
modules/ help/ src/ Plugin/ HelpSection/ HelpTopicSection.php, line 126
Class
- HelpTopicSection
- Provides the help topics list section for the help page.
Namespace
Drupal\help\Plugin\HelpSectionCode
protected function getPlugins() {
if (!isset($this->topLevelPlugins)) {
$definitions = $this->pluginManager
->getDefinitions();
$this->topLevelPlugins = [];
// Get all the top level topics and merge their list cache tags.
foreach ($definitions as $definition) {
if ($definition['top_level']) {
$this->topLevelPlugins[$definition['id']] = $this->pluginManager
->createInstance($definition['id']);
}
}
// Sort the top level topics by label and, if the labels match, then by
// plugin ID.
usort($this->topLevelPlugins, function (HelpTopicPluginInterface $a, HelpTopicPluginInterface $b) {
$a_label = (string) $a->getLabel();
$b_label = (string) $b->getLabel();
if ($a_label === $b_label) {
return $a->getPluginId() <=> $b->getPluginId();
}
return strnatcasecmp($a_label, $b_label);
});
}
return $this->topLevelPlugins;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.