/** * {@inheritdoc} */ public function addExpressionObject(ExpressionInterface $expression) { if (!$expression instanceof ActionExpressionInterface) { throw new InvalidExpressionException('Only action expressions can be added to an action container.'); } if ($this->getExpression($expression->getUuid())) { throw new InvalidExpressionException('An action with the same UUID already exists in the container.'); } $this->actions[] = $expression; return $this; }
/** * {@inheritdoc} */ public function getRoot() { if (isset($this->root)) { return $this->root->getRoot(); } return $this; }
/** * {@inheritdoc} */ public function prepareExecutionMetadataState(ExecutionMetadataStateInterface $metadata_state, ExpressionInterface $until = NULL, $apply_assertions = TRUE) { if ($until && $this->getUuid() === $until->getUuid()) { return TRUE; } $this->prepareExecutionMetadataStateBeforeTraversal($metadata_state); $apply_assertions = $apply_assertions && $this->allowsMetadataAssertions(); foreach ($this as $child_expression) { $found = $child_expression->prepareExecutionMetadataState($metadata_state, $until, $apply_assertions); // If the expression was found, we need to stop. if ($found) { return TRUE; } } $this->prepareExecutionMetadataStateAfterTraversal($metadata_state); }
/** * {@inheritdoc} */ public function getRoot() { if (isset($this->root)) { // @todo: This seems to be the parent, not root. return $this->root->getRoot(); } return $this; }
/** * Verifies that the given expression is valid with the defined context. * * @return \Drupal\rules\Engine\IntegrityViolationList * A list object containing \Drupal\rules\Engine\IntegrityViolation objects. */ public function checkIntegrity() { $data_definitions = []; foreach ($this->contextDefinitions as $name => $context_definition) { $data_definitions[$name] = $context_definition->getDataDefinition(); } $metadata_state = ExecutionMetadataState::create($data_definitions); return $this->expression->checkIntegrity($metadata_state); }
/** * Sets a Rules expression instance for this Rules component. * * @param \Drupal\rules\Engine\ExpressionInterface $expression * The expression to set. * * @return $this */ public function setExpression(ExpressionInterface $expression) { $this->expression = $expression; $this->expression_id = $expression->getPluginId(); $this->configuration = $expression->getConfiguration(); return $this; }
/** * {@inheritdoc} */ 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); } }
/** * Sets a Rules expression instance for this Rules component. * * @param \Drupal\rules\Engine\ExpressionInterface $expression * The expression to set. * * @return $this */ public function setExpression(ExpressionInterface $expression) { $this->component['expression'] = $expression->getConfiguration(); unset($this->componentObject); return $this; }
/** * Verifies that the given expression is valid with the defined context. * * @return \Drupal\rules\Engine\IntegrityViolationList * A list object containing \Drupal\rules\Engine\IntegrityViolation objects. */ public function checkIntegrity() { $metadata_state = $this->getMetadataState(); return $this->expression->checkIntegrity($metadata_state); }
/** * Gets a Rules expression instance for this Reaction rule. * * @return \Drupal\rules\Engine\ExpressionInterface * A Rules expression instance. */ public function getExpression() { // Ensure that an executable Rules expression is available. if (!isset($this->expression)) { $this->expression = $this->getExpressionManager()->createInstance($this->expression_id, $this->configuration); $this->expression->setConfigEntityId($this->id()); } return $this->expression; }
/** * Sets a Rules expression instance for this Reaction rule. * * @param \Drupal\rules\Engine\ExpressionInterface $expression * The expression to set. * * @return $this */ public function setExpression(ExpressionInterface $expression) { $this->expressionObject = $expression; $this->expression = $expression->getConfiguration(); return $this; }