ConditionInterface.php 3.0 KB

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