action.module 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * @file
  4. * This is the Actions module for executing stored actions.
  5. */
  6. use Drupal\Core\Routing\RouteMatchInterface;
  7. /**
  8. * Implements hook_help().
  9. */
  10. function action_help($route_name, RouteMatchInterface $route_match) {
  11. switch ($route_name) {
  12. case 'help.page.action':
  13. $output = '';
  14. $output .= '<h3>' . t('About') . '</h3>';
  15. $output .= '<p>' . t('The Actions 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 Actions module</a>.', [':documentation' => 'https://www.drupal.org/documentation/modules/action']) . '</p>';
  16. $output .= '<h3>' . t('Uses') . '</h3>';
  17. $output .= '<dl>';
  18. $output .= '<dt>' . t('Using simple actions') . '</dt>';
  19. $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>.', [':actions' => \Drupal::url('entity.action.collection')]) . '</dd>';
  20. $output .= '<dt>' . t('Creating and configuring advanced actions') . '</dt>';
  21. $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.', [':actions' => \Drupal::url('entity.action.collection')]) . '</dd>';
  22. $output .= '</dl>';
  23. return $output;
  24. case 'entity.action.collection':
  25. $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>';
  26. return $output;
  27. case 'action.admin_add':
  28. case 'entity.action.edit_form':
  29. return t('An advanced action offers additional configuration options which may be filled out below. Changing the <em>Label</em> field is recommended in order to better identify the precise action taking place.');
  30. }
  31. }
  32. /**
  33. * Implements hook_entity_type_build().
  34. */
  35. function action_entity_type_build(array &$entity_types) {
  36. /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
  37. $entity_types['action']
  38. ->setFormClass('add', 'Drupal\action\ActionAddForm')
  39. ->setFormClass('edit', 'Drupal\action\ActionEditForm')
  40. ->setFormClass('delete', 'Drupal\action\Form\ActionDeleteForm')
  41. ->setListBuilderClass('Drupal\action\ActionListBuilder')
  42. ->setLinkTemplate('delete-form', '/admin/config/system/actions/configure/{action}/delete')
  43. ->setLinkTemplate('edit-form', '/admin/config/system/actions/configure/{action}')
  44. ->setLinkTemplate('collection', '/admin/config/system/actions');
  45. }