public function ConditionExpression::checkIntegrity in Rules 8.3
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().
Parameters
\Drupal\rules\Context\ExecutionMetadataStateInterface $metadata_state: The execution metadata state, prepared until right before this expression.
bool $apply_assertions: (optional) Whether to apply metadata assertions while preparing the execution metadata state. Defaults to TRUE.
Return value
\Drupal\rules\Engine\IntegrityViolationList A list object containing \Drupal\rules\Engine\IntegrityViolation objects.
Overrides ExpressionInterface::checkIntegrity
See also
::prepareExecutionMetadataState()
File
- src/
Plugin/ RulesExpression/ ConditionExpression.php, line 183
Class
- ConditionExpression
- Defines an executable condition expression.
Namespace
Drupal\rules\Plugin\RulesExpressionCode
public function checkIntegrity(ExecutionMetadataStateInterface $metadata_state, $apply_assertions = TRUE) {
$violation_list = new IntegrityViolationList();
if (empty($this->configuration['condition_id'])) {
$violation_list
->addViolationWithMessage($this
->t('Condition plugin ID is missing'), $this
->getUuid());
return $violation_list;
}
if (!$this->conditionManager
->hasDefinition($this->configuration['condition_id'])) {
$violation_list
->addViolationWithMessage($this
->t('Condition plugin %plugin_id does not exist', [
'%plugin_id' => $this->configuration['condition_id'],
]), $this
->getUuid());
return $violation_list;
}
$condition = $this->conditionManager
->createInstance($this->configuration['condition_id'], [
'negate' => $this->configuration['negate'],
]);
// Prepare and refine the context before checking integrity, such that any
// context definition changes are respected while checking.
$this
->prepareContextWithMetadata($condition, $metadata_state);
$result = $this
->checkContextConfigIntegrity($condition, $metadata_state);
$this
->prepareExecutionMetadataState($metadata_state, NULL, $apply_assertions);
return $result;
}