action.module 3.34 KB
Newer Older
1 2 3 4 5 6 7
<?php

/**
 * @file
 * This is the Actions module for executing stored actions.
 */

8
use Drupal\Core\Routing\RouteMatchInterface;
9

10 11 12
/**
 * Implements hook_help().
 */
13
function action_help($route_name, RouteMatchInterface $route_match) {
14 15
  switch ($route_name) {
    case 'help.page.action':
16 17
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
18
      $output .= '<p>' . t('The Action module provides tasks that can be executed by the site such as unpublishing content, sending email messages, or blocking a user. Other modules can trigger these actions when specific system events happen; for example, when new content is posted or when a user logs in. Modules can also provide additional actions. For more information, see the <a href="!documentation">online documentation for the Action module</a>.', array('!documentation' => 'https://drupal.org/documentation/modules/action')) . '</p>';
19 20 21
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Using simple actions') . '</dt>';
22
      $output .= '<dd>' . t('<em>Simple actions</em> do not require configuration and are listed automatically as available on the <a href="!actions">Actions page</a>.', array('!actions' => \Drupal::url('action.admin'))) . '</dd>';
23
      $output .= '<dt>' . t('Creating and configuring advanced actions') . '</dt>';
24
      $output .= '<dd>' . t('<em>Advanced actions</em> are user-created and have to be configured individually. Create an advanced action on the <a href="!actions">Actions page</a> by selecting an action type from the drop-down list. Then configure your action, for example by specifying the recipient of an automated email message.', array('!actions' => \Drupal::url('action.admin'))) . '</dd>';
25
      $output .= '</dl>';
26 27
      return $output;

28
    case 'action.admin':
29
      $output = '<p>' . t('There are two types of actions: simple and advanced. Simple actions do not require any additional configuration and are listed here automatically. Advanced actions need to be created and configured before they can be used because they have options that need to be specified; for example, sending an email to a specified address or unpublishing content containing certain words. To create an advanced action, select the action from the drop-down list in the advanced action section below and click the <em>Create</em> button.') . '</p>';
30 31
      return $output;

32
    case 'action.admin_configure':
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
      return t('An advanced action offers additional configuration options which may be filled out below. Changing the <em>Description</em> field is recommended in order to better identify the precise action taking place.');
  }
}

/**
 * Implements hook_permission().
 */
function action_permission() {
  return array(
    'administer actions' => array(
      'title' => t('Administer actions'),
    ),
  );
}

/**
49
 * Implements hook_entity_type_build().
50
 */
51 52 53
function action_entity_type_build(array &$entity_types) {
  /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
  $entity_types['action']
54 55
    ->setFormClass('add', 'Drupal\action\ActionAddForm')
    ->setFormClass('edit', 'Drupal\action\ActionEditForm')
56
    ->setFormClass('delete', 'Drupal\action\Form\ActionDeleteForm')
57
    ->setListBuilderClass('Drupal\action\ActionListBuilder')
58
    ->setLinkTemplate('delete-form', 'action.delete')
59
    ->setLinkTemplate('edit-form', 'action.admin_configure');
60
}