예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function checkIntegrity(ExecutionMetadataStateInterface $metadata_state)
 {
     $violation_list = new IntegrityViolationList();
     if (empty($this->configuration['list'])) {
         $violation_list->addViolationWithMessage($this->t('List variable is missing.'));
         return $violation_list;
     }
     try {
         $list_definition = $metadata_state->fetchDefinitionByPropertyPath($this->configuration['list']);
     } catch (RulesIntegrityException $e) {
         $violation_list->addViolationWithMessage($this->t('List variable %list does not exist. @message', ['%list' => $this->configuration['list'], '@message' => $e->getMessage()]));
         return $violation_list;
     }
     $list_item_name = isset($this->configuration['list_item']) ? $this->configuration['list_item'] : 'list_item';
     if ($metadata_state->hasDataDefinition($list_item_name)) {
         $violation_list->addViolationWithMessage($this->t('List item name %name conflicts with an existing variable.', ['%name' => $list_item_name]));
         return $violation_list;
     }
     if ($list_definition instanceof ListDataDefinitionInterface) {
         $list_item_definition = $list_definition->getItemDefinition();
         $metadata_state->setDataDefinition($list_item_name, $list_item_definition);
         $violation_list = parent::checkIntegrity($metadata_state);
         // Remove the list item variable after the loop, it is out of scope now.
         $metadata_state->removeDataDefinition($list_item_name);
         return $violation_list;
     }
     $violation_list->addViolationWithMessage($this->t('The data type of list variable %list is not a list.', ['%list' => $this->configuration['list']]));
     return $violation_list;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function checkIntegrity(ExecutionMetadataStateInterface $metadata_state, $apply_assertions = TRUE)
 {
     $violation_list = new IntegrityViolationList();
     if (empty($this->configuration['action_id'])) {
         $violation_list->addViolationWithMessage($this->t('Action plugin ID is missing'), $this->getUuid());
         return $violation_list;
     }
     if (!$this->actionManager->hasDefinition($this->configuration['action_id'])) {
         $violation_list->addViolationWithMessage($this->t('Action plugin %plugin_id does not exist', ['%plugin_id' => $this->configuration['action_id']]), $this->getUuid());
         return $violation_list;
     }
     $action = $this->actionManager->createInstance($this->configuration['action_id']);
     // Prepare and refine the context before checking integrity, such that any
     // context definition changes are respected while checking.
     $this->prepareContextWithMetadata($action, $metadata_state);
     $result = $this->checkContextConfigIntegrity($action, $metadata_state);
     $this->prepareExecutionMetadataState($metadata_state, NULL, $apply_assertions);
     return $result;
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function checkIntegrity(ExecutionMetadataStateInterface $metadata_state)
 {
     $violation_list = new IntegrityViolationList();
     if (empty($this->configuration['action_id'])) {
         $violation_list->addViolationWithMessage($this->t('Action plugin ID is missing'));
         return $violation_list;
     }
     if (!$this->actionManager->hasDefinition($this->configuration['action_id'])) {
         $violation_list->addViolationWithMessage($this->t('Action plugin %plugin_id does not exist', ['%plugin_id' => $this->configuration['action_id']]));
         return $violation_list;
     }
     $action = $this->actionManager->createInstance($this->configuration['action_id']);
     return $this->doCheckIntegrity($action, $metadata_state);
 }