Same name and namespace in other branches
  1. 7.x-2.x easy_breadcrumb.module \easy_breadcrumb_help() 1 comment
  2. 8.x-1.x easy_breadcrumb.module \easy_breadcrumb_help() 1 comment

Implements hook_help().

File

./easy_breadcrumb.module, line 13

Code

function easy_breadcrumb_help($route_name) {
    switch ($route_name) {
        case 'help.page.easy_breadcrumb':
            $text = file_get_contents(__DIR__ . "/README.md");
            // If the Markdown module is installed...
            if (\Drupal::moduleHandler()->moduleExists('markdown') === TRUE) {
                // Uses the Markdown filter to render the README.
                $filter_manager = \Drupal::service('plugin.manager.filter');
                $settings = \Drupal::configFactory()->get('markdown.settings')
                    ->getRawData();
                $config = [
                    'settings' => $settings,
                ];
                $filter = $filter_manager->createInstance('markdown', $config);
                $output = $filter->process($text, 'en');
            }
            else {
                // Outputs the README in plain text.
                $output = '<pre>' . $text . '</pre>';
            }
            // Adds a link to the Drupal.org documentation pages.
            $output .= t('<p>See the <a href=":documentation">documentation pages</a> on Drupal.org for more information.</p>', [
                ':documentation' => 'https://www.drupal.org/docs/8/improve-the-breadcrumbs',
            ]);
            return $output;
    }
}