function ConditionExpression::checkIntegrity

Overrides ExpressionInterface::checkIntegrity

File

src/Plugin/RulesExpression/ConditionExpression.php, line 183

Class

ConditionExpression
Defines an executable condition expression.

Namespace

Drupal\rules\Plugin\RulesExpression

Code

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;
}