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