function ActionExpressionContainer::addExpressionObject

Overrides ExpressionContainerInterface::addExpressionObject

1 call to ActionExpressionContainer::addExpressionObject()
ActionExpressionContainer::addAction in src/Engine/ActionExpressionContainer.php
Creates an action expression and adds it to the container.

File

src/Engine/ActionExpressionContainer.php, line 51

Class

ActionExpressionContainer
Container for actions.

Namespace

Drupal\rules\Engine

Code

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