function ConditionExpressionContainer::addExpressionObject

Overrides ExpressionContainerInterface::addExpressionObject

1 call to ConditionExpressionContainer::addExpressionObject()
ConditionExpressionContainer::addCondition in src/Engine/ConditionExpressionContainer.php
Creates a condition expression and adds it to the container.

File

src/Engine/ConditionExpressionContainer.php, line 52

Class

ConditionExpressionContainer
Container for conditions.

Namespace

Drupal\rules\Engine

Code

public function addExpressionObject(ExpressionInterface $expression) {
    if (!$expression instanceof ConditionExpressionInterface) {
        throw new InvalidExpressionException('Only condition expressions can be added to a condition container.');
    }
    $uuid = $expression->getUuid();
    if ($this->getExpression($uuid)) {
        throw new InvalidExpressionException("A condition with UUID {$uuid} already exists in the container.");
    }
    $this->conditions[] = $expression;
    return $this;
}