3 namespace Drupal\help\Plugin\HelpSection;
5 use Drupal\Core\Extension\ModuleHandlerInterface;
7 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
8 use Symfony\Component\DependencyInjection\ContainerInterface;
11 * Provides the module topics list section for the help page.
15 * title = @Translation("Module overviews"),
16 * description = @Translation("Module overviews are provided by modules. Overviews available for your installed modules:"),
19 class HookHelpSection extends HelpSectionPluginBase implements ContainerFactoryPluginInterface {
24 * @var \Drupal\Core\Extension\ModuleHandlerInterface
26 protected $moduleHandler;
29 * Constructs a HookHelpSection object.
31 * @param array $configuration
32 * A configuration array containing information about the plugin instance.
33 * @param string $plugin_id
34 * The plugin_id for the plugin instance.
35 * @param mixed $plugin_definition
36 * The plugin implementation definition.
37 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
38 * The module handler service.
40 public function __construct(array $configuration, $plugin_id, $plugin_definition, ModuleHandlerInterface $module_handler) {
41 parent::__construct($configuration, $plugin_id, $plugin_definition);
42 $this->moduleHandler = $module_handler;
48 public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
53 $container->get('module_handler')
60 public function listTopics() {
62 foreach ($this->moduleHandler->getImplementations('help') as $module) {
63 $title = $this->moduleHandler->getName($module);
64 $topics[$title] = Link::createFromRoute($title, 'help.page', ['name' => $module]);
67 // Sort topics by title, which is the array key above.