You are here

function lazy_help in Lazy-load 8.3

Same name and namespace in other branches
  1. 8 lazy.module \lazy_help()
  2. 8.2 lazy.module \lazy_help()
  3. 7 lazy.module \lazy_help()

Implements hook_help().

File

./lazy.module, line 18
Module file for Lazy-load.

Code

function lazy_help($route_name) {
  switch ($route_name) {
    case 'help.page.lazy':
      $readme = 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');
        $settings = \Drupal::configFactory()
          ->get('markdown.settings')
          ->getRawData();
        $config = [
          'settings' => $settings,
        ];
        $filter = $filter_manager
          ->createInstance('markdown', $config);
        return $filter
          ->process($readme, 'en');
      }
      return '<pre>' . $readme . '</pre>';
  }
  return NULL;
}