You are here

function oauth2_client_help in OAuth2 Client 8.3

Same name and namespace in other branches
  1. 8.2 oauth2_client.module \oauth2_client_help()

Implements hook_help().

File

./oauth2_client.module, line 13
Holds hooks for the OAuth2 Client module.

Code

function oauth2_client_help($route_name, RouteMatchInterface $route_match) {
  if ($route_name === 'help.page.oauth2_client') {
    $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,
      ];
    }
  }
}