You are here

function config_pages_help in Config Pages 8.3

Same name and namespace in other branches
  1. 8.2 config_pages.module \config_pages_help()

Implements hook_help().

File

./config_pages.module, line 57
Module hooks.

Code

function config_pages_help($route_name, RouteMatchInterface $route_match) {
  if ($route_name === 'help.page.config_pages') {
    $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);
      return $filter
        ->process($readme_content, 'en');
    }
    else {
      return '<pre>' . $readme_content . '</pre>';
    }
  }
}