You are here

function devel_mail_logger_help in Devel Mail Logger 8

Same name and namespace in other branches
  1. 7 devel_mail_logger.module \devel_mail_logger_help()

Implements hook_help().

File

./devel_mail_logger.module, line 14
Contains devel_mail_logger.module.

Code

function devel_mail_logger_help($route_name, RouteMatchInterface $route_match) {
  if ($route_name === 'help.page.devel_mail_logger') {
    $readme_content = file_get_contents(__DIR__ . '/README.md');
    if (\Drupal::moduleHandler()
      ->moduleExists('markdown')) {

      // Use the Markdown filter to render the README.
      $filter_manager = \Drupal::service('plugin.manager.filter');
      $markdown_config = \Drupal::configFactory()
        ->get('markdown.settings')
        ->getRawData();
      $markdown_settings = [
        'settings' => $markdown_config,
      ];

      /** @var \Drupal\markdown\Plugin\Filter\MarkdownFilterInterface $filter */
      $filter = $filter_manager
        ->createInstance('markdown', $markdown_settings);
      return $filter
        ->process($readme_content, 'en');
    }
    else {
      return [
        '#type' => 'html_tag',
        '#tag' => 'pre',
        '#value' => $readme_content,
      ];
    }
  }
}