You are here

key.module in Key 8

Same filename and directory in other branches
  1. 7.3 key.module
  2. 7 key.module
  3. 7.2 key.module

Hook implementations and general functionality for Key.

File

key.module
View source
<?php

/**
 * @file
 * Hook implementations and general functionality for Key.
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function key_help($route_name, RouteMatchInterface $route_match) {
  if ($route_name === 'help.page.key') {
    $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>';
    }
  }
}

Functions

Namesort descending Description
key_help Implements hook_help().