You are here

bootstrap_datepicker.module in Bootstrap Datepicker 8

Hook implementation for bootstrap_datepicker.module.

File

bootstrap_datepicker.module
View source
<?php

/**
 * @file
 * Hook implementation for bootstrap_datepicker.module.
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * @file
 * Bootstrap Datepicker implements.
 *
 * See https://github.com/uxsolutions/bootstrap-datepicker as a datepicker.
 */

/**
 * Implements hook_help().
 */
function bootstrap_datepicker_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.bootstrap_datepicker':
      $readme = __DIR__ . '/README.txt';
      $text = file_get_contents($readme);
      $output = '';

      // If the Markdown module is installed, use it to render the README.
      if ($text && \Drupal::moduleHandler()
        ->moduleExists('markdown') === TRUE) {
        $filter_manager = \Drupal::service('plugin.manager.filter');
        $settings = \Drupal::configFactory()
          ->get('markdown.settings')
          ->getRawData();
        $config = [
          'settings' => $settings,
        ];
        $filter = $filter_manager
          ->createInstance('markdown', $config);
        $output = $filter
          ->process($text, 'en');
      }
      elseif ($text) {
        $output = '<pre>' . $text . '</pre>';
      }

      // Add a link to the Drupal.org project.
      $output .= '<p>';
      $output .= t('Visit the <a href=":project_link">project pages</a> on Drupal.org for more information.', [
        ':project_link' => 'https://www.drupal.org/project/bootstrap_datepicker',
      ]);
      $output .= '</p>';
      return $output;
  }
}

Functions

Namesort descending Description
bootstrap_datepicker_help Implements hook_help().