public function ReadmeHookHelpSection::listTopics in README Help 8
Returns a list of topics to show in the help section.
Return value
array A sorted list of topic links or render arrays for topic links. The links will be shown in the help section; if the returned array of links is empty, the section will be shown with some generic empty text.
Overrides HookHelpSection::listTopics
File
- src/
Plugin/ HelpSection/ ReadmeHookHelpSection.php, line 23
Class
- ReadmeHookHelpSection
- Provides the module topics list section for the help page.
Namespace
Drupal\readmehelp\Plugin\HelpSectionCode
public function listTopics() {
$dirs = $this->moduleHandler
->getModuleDirectories();
$hook_help = $this->moduleHandler
->getImplementations('help');
$topics = [];
foreach ($this->moduleHandler
->getModuleList() as $name => $module) {
$file = FALSE;
$self = $name == 'readmehelp';
$extension_info = \Drupal::service('extension.list.module')
->getExtensionInfo($name);
$dependencies = $extension_info['dependencies'];
if (in_array('readmehelp', $dependencies) || in_array('drupal:readmehelp', $dependencies) || $self) {
foreach (explode(', ', static::READMEHELP_FILES) as $readme) {
if ($file = file_exists("{$dirs[$name]}/{$readme}")) {
break;
}
}
}
if ($file || in_array($name, $hook_help)) {
$title = $this->moduleHandler
->getName($name);
$topics[$title] = Link::createFromRoute($title, 'help.page', [
'name' => $name,
]);
}
}
// Sort topics by title, which is the array key above.
ksort($topics);
return $topics;
}