ActionInterface.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace Drupal\Core\Action;
  3. use Drupal\Component\Plugin\PluginInspectionInterface;
  4. use Drupal\Core\Executable\ExecutableInterface;
  5. use Drupal\Core\Session\AccountInterface;
  6. /**
  7. * Provides an interface for an Action plugin.
  8. *
  9. * @todo WARNING: The action API is going to receive some additions before
  10. * release. The following additions are likely to happen:
  11. * - The way configuration is handled and configuration forms are built is
  12. * likely to change in order for the plugin to be of use for Rules.
  13. * - Actions are going to become context-aware in
  14. * https://www.drupal.org/node/2011038, what will deprecated the 'type'
  15. * annotation.
  16. * - Instead of action implementations saving entities, support for marking
  17. * required context as to be saved by the execution manager will be added as
  18. * part of https://www.drupal.org/node/2347017.
  19. * - Actions will receive a data processing API that allows for token
  20. * replacements to happen outside of the action plugin implementations,
  21. * see https://www.drupal.org/node/2347023.
  22. *
  23. * @see \Drupal\Core\Annotation\Action
  24. * @see \Drupal\Core\Action\ActionManager
  25. * @see \Drupal\Core\Action\ActionBase
  26. * @see plugin_api
  27. */
  28. interface ActionInterface extends ExecutableInterface, PluginInspectionInterface {
  29. /**
  30. * Executes the plugin for an array of objects.
  31. *
  32. * @param array $objects
  33. * An array of entities.
  34. */
  35. public function executeMultiple(array $objects);
  36. /**
  37. * Checks object access.
  38. *
  39. * @param mixed $object
  40. * The object to execute the action on.
  41. * @param \Drupal\Core\Session\AccountInterface $account
  42. * (optional) The user for which to check access, or NULL to check access
  43. * for the current user. Defaults to NULL.
  44. * @param bool $return_as_object
  45. * (optional) Defaults to FALSE.
  46. *
  47. * @return bool|\Drupal\Core\Access\AccessResultInterface
  48. * The access result. Returns a boolean if $return_as_object is FALSE (this
  49. * is the default) and otherwise an AccessResultInterface object.
  50. * When a boolean is returned, the result of AccessInterface::isAllowed() is
  51. * returned, i.e. TRUE means access is explicitly allowed, FALSE means
  52. * access is either explicitly forbidden or "no opinion".
  53. */
  54. public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE);
  55. }