You are here

function menu_manipulator_help in Menu Manipulator 8

Same name and namespace in other branches
  1. 8.2 menu_manipulator.module \menu_manipulator_help()
  2. 3.0.x menu_manipulator.module \menu_manipulator_help()
  3. 2.0.x menu_manipulator.module \menu_manipulator_help()

Implements hook_help().

@inheritdoc

File

./menu_manipulator.module, line 17
Contains menu_manipulator.module.

Code

function menu_manipulator_help($route_name, CurrentRouteMatch $route_match) {
  if ($route_name == 'help.page.menu_manipulator') {
    $text = file_get_contents(dirname(__FILE__) . '/README.md');
    if (!\Drupal::moduleHandler()
      ->moduleExists('markdown')) {
      return '<pre>' . $text . '</pre>';
    }
    else {

      // 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($text, 'en');
    }
  }
  return NULL;
}