You are here

function node_read_time_help in Node read time 8

Implements hook_help().

File

./node_read_time.module, line 15
Reading time module.

Code

function node_read_time_help($route_name, RouteMatchInterface $route_match) {
  if ($route_name === 'help.page.node_read_time') {
    $readme_content = file_get_contents(dirname(__FILE__) . '/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,
      ];
      $filter = $filter_manager
        ->createInstance('markdown', $markdown_settings);
      $readme_content = $filter
        ->process($readme_content, 'en');
    }
    else {
      $readme_content = '<pre>' . $readme_content . '</pre>';
    }
    return $readme_content;
  }
}