public function ActionExpression::prepareExecutionMetadataState in Rules 8.3
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.
Parameters
\Drupal\rules\Context\ExecutionMetadataStateInterface $metadata_state: The execution metadata state, prepared until right before this expression.
\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.
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 value
true|null True if the metadata has been prepared and the $until expression was found in the tree. Null otherwise.
Overrides ExpressionInterface::prepareExecutionMetadataState
1 call to ActionExpression::prepareExecutionMetadataState()
- ActionExpression::checkIntegrity in src/
Plugin/ RulesExpression/ ActionExpression.php - Verifies that this expression is configured correctly.
File
- src/
Plugin/ RulesExpression/ ActionExpression.php, line 173
Class
- ActionExpression
- Provides an executable action expression.
Namespace
Drupal\rules\Plugin\RulesExpressionCode
public function prepareExecutionMetadataState(ExecutionMetadataStateInterface $metadata_state, ExpressionInterface $until = NULL, $apply_assertions = TRUE) {
if ($until && $this
->getUuid() === $until
->getUuid()) {
return TRUE;
}
$action = $this->actionManager
->createInstance($this->configuration['action_id']);
// Make sure to refine context first, such that possibly refined definitions
// of provided context are respected.
$this
->prepareContextWithMetadata($action, $metadata_state);
$this
->addProvidedContextDefinitions($action, $metadata_state);
if ($apply_assertions) {
$this
->assertMetadata($action, $metadata_state);
}
}