ConditionInterface.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace Drupal\Core\Condition;
  3. use Drupal\Component\Plugin\ConfigurablePluginInterface;
  4. use Drupal\Component\Plugin\PluginInspectionInterface;
  5. use Drupal\Core\Cache\CacheableDependencyInterface;
  6. use Drupal\Core\Executable\ExecutableInterface;
  7. use Drupal\Core\Executable\ExecutableManagerInterface;
  8. use Drupal\Core\Plugin\PluginFormInterface;
  9. /**
  10. * An interface for condition plugins.
  11. *
  12. * Condition plugins are context-aware and configurable. They support the
  13. * following keys in their plugin definitions:
  14. * - context: An array of context definitions, keyed by context name. Each
  15. * context definition is a typed data definition describing the context. Check
  16. * the typed data definition docs for details.
  17. * - configuration: An array of configuration option definitions, keyed by
  18. * option name. Each option definition is a typed data definition describing
  19. * the configuration option. Check the typed data definition docs for details.
  20. *
  21. * @todo Replace the dependency on \Drupal\Core\Form\FormInterface with a new
  22. * interface from https://www.drupal.org/node/2006248.
  23. * @todo WARNING: The condition API is going to receive some additions before release.
  24. * The following additions are likely to happen:
  25. * - The way configuration is handled and configuration forms are built is
  26. * likely to change in order for the plugin to be of use for Rules.
  27. * - Conditions will receive a data processing API that allows for token
  28. * replacements to happen outside of the plugin implementations,
  29. * see https://www.drupal.org/node/2347023.
  30. * - Conditions will have to implement access control for checking who is
  31. * allowed to configure or perform the action at
  32. * https://www.drupal.org/node/2172017.
  33. *
  34. * @see \Drupal\Core\TypedData\TypedDataManager::create()
  35. * @see \Drupal\Core\Executable\ExecutableInterface
  36. * @see \Drupal\Core\Condition\ConditionManager
  37. * @see \Drupal\Core\Condition\Annotation\Condition
  38. * @see \Drupal\Core\Condition\ConditionPluginBase
  39. *
  40. * @ingroup plugin_api
  41. */
  42. interface ConditionInterface extends ExecutableInterface, PluginFormInterface, ConfigurablePluginInterface, PluginInspectionInterface, CacheableDependencyInterface {
  43. /**
  44. * Determines whether condition result will be negated.
  45. *
  46. * @return bool
  47. * Whether the condition result will be negated.
  48. */
  49. public function isNegated();
  50. /**
  51. * Evaluates the condition and returns TRUE or FALSE accordingly.
  52. *
  53. * @return bool
  54. * TRUE if the condition has been met, FALSE otherwise.
  55. */
  56. public function evaluate();
  57. /**
  58. * Provides a human readable summary of the condition's configuration.
  59. */
  60. public function summary();
  61. /**
  62. * Sets the executable manager class.
  63. *
  64. * @param \Drupal\Core\Executable\ExecutableManagerInterface $executableManager
  65. * The executable manager.
  66. */
  67. public function setExecutableManager(ExecutableManagerInterface $executableManager);
  68. }