You are here

tour_ui.module in Tour UI 8

Core functionality for Tour UI module.

File

tour_ui.module
View source
<?php

/**
 * @file
 * Core functionality for Tour UI module.
 */
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function tour_ui_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.tour_ui':
      $output = '<p>' . t('Provides a user interface for Tour module in Drupal 8 core.') . '</p>';
      return $output;
  }
}

/**
 * Implements hook_entity_type_alter().
 */
function tour_ui_entity_type_alter(array &$entity_types) {
  $entity_types['tour']
    ->setAccessClass('Drupal\\tour_ui\\TourAccessControlHandler');
  $entity_types['tour']
    ->setFormClass('default', 'Drupal\\tour_ui\\Form\\TourForm');
  $entity_types['tour']
    ->setFormClass('add', 'Drupal\\tour_ui\\Form\\TourForm');
  $entity_types['tour']
    ->setFormClass('edit', 'Drupal\\tour_ui\\Form\\TourForm');
  $entity_types['tour']
    ->setFormClass('delete', 'Drupal\\tour_ui\\Form\\TourDeleteForm');
  $entity_types['tour']
    ->setListBuilderClass('Drupal\\tour_ui\\TourListBuilder');
  $entity_types['tour']
    ->setLinkTemplate('add-form', '/admin/config/user-interface/tour/add');
  $entity_types['tour']
    ->setLinkTemplate('edit-form', '/admin/config/user-interface/tour/manage/{tour}');
  $entity_types['tour']
    ->setLinkTemplate('delete-form', '/admin/config/user-interface/tour/manage/{tour}/delete');
}

/**
 * Implements hook_tour_tips_info_alter().
 */
function tour_ui_tour_tips_info_alter(&$info) {

  // Override the core text plugin.
  if (isset($info['text'])) {
    $info['text']['class'] = 'Drupal\\tour_ui\\Plugin\\tour_ui\\tip\\TipPluginTextExtended';
  }
}

/**
 * Implements hook_module_implements_alter().
 */
function tour_ui_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'entity_type_alter') {

    // Move tour_ui before others.
    unset($implementations['tour_ui']);
    $implementations = [
      'tour_ui' => FALSE,
    ] + $implementations;
  }
}