You are here

function cookiebot_help in Cookiebot - Cookie consent, Cookie monitoring and Cookie control 8

Same name and namespace in other branches
  1. 7 cookiebot.module \cookiebot_help()

Implements hook_help().

File

./cookiebot.module, line 15
The module file.

Code

function cookiebot_help($route_name) {
  if ($route_name !== 'help.page.cookiebot') {
    return '';
  }
  $text = file_get_contents(drupal_get_path('module', 'cookiebot') . '/README.md');
  if (!\Drupal::moduleHandler()
    ->moduleExists('markdown')) {
    return [
      '#markup' => str_replace("\n", '<br />', $text),
      '#allowed_tags' => [
        'br',
      ],
    ];
  }
  $filters = new FilterPluginCollection(\Drupal::service('plugin.manager.filter'));
  $filter = $filters
    ->get('markdown');
  $text = $filter
    ->process($text, \Drupal::languageManager()
    ->getCurrentLanguage()
    ->getId());
  return $text
    ->getProcessedText();
}