interface ExpressionInterface

Defines the interface for Rules expressions.

Hierarchy

Expanded class hierarchy of ExpressionInterface

All classes that implement ExpressionInterface

See also

\Drupal\rules\Engine\ExpressionManager

5 files declare their use of ExpressionInterface
ActionExpression.php in src/Plugin/RulesExpression/ActionExpression.php
ConditionExpression.php in src/Plugin/RulesExpression/ConditionExpression.php
ReactionRuleConfig.php in src/Entity/ReactionRuleConfig.php
RuleExpression.php in src/Plugin/RulesExpression/RuleExpression.php
RulesComponentConfig.php in src/Entity/RulesComponentConfig.php

File

src/Engine/ExpressionInterface.php, line 17

Namespace

Drupal\rules\Engine
View source
interface ExpressionInterface extends ExecutableInterface, ConfigurableInterface, DependentPluginInterface, PluginInspectionInterface {
    
    /**
     * Execute the expression with a given Rules state.
     *
     * Note that this does not auto-save any changes.
     *
     * @param \Drupal\rules\Context\ExecutionStateInterface $state
     *   The state with all the execution variables in it.
     *
     * @return null|bool
     *   The expression may return a boolean value after execution, this is used
     *   by conditions that return their evaluation result.
     *
     * @throws \Drupal\rules\Exception\EvaluationException
     *   Thrown if the Rules expression triggers errors during execution.
     */
    public function executeWithState(ExecutionStateInterface $state);
    
    /**
     * Returns the form handling class for this expression.
     *
     * @return \Drupal\rules\Form\Expression\ExpressionFormInterface|null
     *   The form handling object if there is one, NULL otherwise.
     */
    public function getFormHandler();
    
    /**
     * Returns the root expression if this expression is nested.
     *
     * @return \Drupal\rules\Engine\ExpressionInterface
     *   The root expression or $this if the expression is the root element
     *   itself.
     */
    public function getRoot();
    
    /**
     * Set the root expression for this expression if it is nested.
     *
     * @param \Drupal\rules\Engine\ExpressionInterface $root
     *   The root expression object.
     *
     * @return $this
     */
    public function setRoot(ExpressionInterface $root);
    
    /**
     * The label of this expression element that can be shown in the UI.
     *
     * @return string
     *   The label for display.
     */
    public function getLabel();
    
    /**
     * Returns the UUID of this expression if it is nested in another expression.
     *
     * @return string|null
     *   The UUID if this expression is nested or NULL if it does not have a UUID.
     */
    public function getUuid();
    
    /**
     * Sets the UUID of this expression in an expression tree.
     *
     * @param string $uuid
     *   The UUID to set.
     *
     * @return $this
     */
    public function setUuid($uuid);
    
    /**
     * Returns the list order of this expression.
     *
     * @return int
     *   The list order of this expression.
     */
    public function getWeight();
    
    /**
     * Sets the list order of this expression in an expression tree.
     *
     * @param int $weight
     *   The weight to set.
     *
     * @return $this
     */
    public function setWeight($weight);
    
    /**
     * Verifies that this expression is configured correctly.
     *
     * Example: All configured data selectors must be valid.
     *
     * Note that for checking integrity the execution metadata state must be
     * passed prepared as achieved by ::prepareExecutionMetadataState() and the
     * expression must apply all metadata state preparations during its integrity
     * check as it does in ::prepareExecutionMetadataState().
     * This allows for efficient integrity checks of expression trees; e.g. see
     * \Drupal\rules\Engine\ActionExpressionContainer::checkIntegrity().
     *
     * @param \Drupal\rules\Context\ExecutionMetadataStateInterface $metadata_state
     *   The execution metadata state, prepared until right before this
     *   expression.
     * @param bool $apply_assertions
     *   (optional) Whether to apply metadata assertions while preparing the
     *   execution metadata state. Defaults to TRUE.
     *
     * @return \Drupal\rules\Engine\IntegrityViolationList
     *   A list object containing \Drupal\rules\Engine\IntegrityViolation objects.
     *
     * @see ::prepareExecutionMetadataState()
     */
    public function checkIntegrity(ExecutionMetadataStateInterface $metadata_state, $apply_assertions = TRUE);
    
    /**
     * Prepares the execution metadata state by adding metadata to it.
     *
     * If this expression contains other expressions then the metadata state is
     * set up recursively. If a $until expression is specified then the setup will
     * stop right before that expression to calculate the state at this execution
     * point.
     * This is useful for inspecting the state at a certain point in the
     * expression tree as needed during configuration, for example to do
     * autocompletion of available variables in the state.
     *
     * The difference to fully preparing the state is that not necessarily all
     * variables are available in the middle of the expression tree, as for
     * example variables being added later are not added yet. Preparing with
     * $until = NULL reflects the execution metadata state at the end of the
     * expression execution.
     *
     * @param \Drupal\rules\Context\ExecutionMetadataStateInterface $metadata_state
     *   The execution metadata state, prepared until right before this
     *   expression.
     * @param \Drupal\rules\Engine\ExpressionInterface $until
     *   (optional) The expression at which metadata preparation should be
     *   stopped. The preparation of the state will be stopped right before that
     *   expression.
     * @param bool $apply_assertions
     *   (optional) Whether to apply metadata assertions while preparing the
     *   execution metadata state. Defaults to TRUE. Metadata assertions should
     *   be only applied if the expression's execution is required for sub-sequent
     *   expressions being executed. For example, if a condition is optional as
     *   it is part of a logical OR expression, its assertions may not be applied.
     *   Defaults to TRUE.
     *
     * @return true|null
     *   True if the metadata has been prepared and the $until expression was
     *   found in the tree. Null otherwise.
     */
    public function prepareExecutionMetadataState(ExecutionMetadataStateInterface $metadata_state, ExpressionInterface $until = NULL, $apply_assertions = TRUE);

}

Members

Title Sort descending Modifiers Object type Summary Overrides
ConfigurableInterface::defaultConfiguration public function Gets default configuration for this plugin. 14
ConfigurableInterface::getConfiguration public function Gets this plugin's configuration. 15
ConfigurableInterface::setConfiguration public function Sets the configuration for this plugin instance. 15
DependentPluginInterface::calculateDependencies public function Calculates dependencies for the configured plugin. 20
ExecutableInterface::execute public function Executes the plugin. 21
ExpressionInterface::checkIntegrity public function Verifies that this expression is configured correctly. 4
ExpressionInterface::executeWithState public function Execute the expression with a given Rules state. 6
ExpressionInterface::getFormHandler public function Returns the form handling class for this expression. 1
ExpressionInterface::getLabel public function The label of this expression element that can be shown in the UI. 1
ExpressionInterface::getRoot public function Returns the root expression if this expression is nested. 1
ExpressionInterface::getUuid public function Returns the UUID of this expression if it is nested in another expression. 1
ExpressionInterface::getWeight public function Returns the list order of this expression. 1
ExpressionInterface::prepareExecutionMetadataState public function Prepares the execution metadata state by adding metadata to it. 4
ExpressionInterface::setRoot public function Set the root expression for this expression if it is nested. 1
ExpressionInterface::setUuid public function Sets the UUID of this expression in an expression tree. 1
ExpressionInterface::setWeight public function Sets the list order of this expression in an expression tree. 1
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 6
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2