/**
  * @param PromotionActionInterface $action
  *
  * @return array
  */
 protected function getConfiguration($action)
 {
     if ($action instanceof PromotionActionInterface && null !== $action->getConfiguration()) {
         return $action->getConfiguration();
     }
     return [];
 }
 /**
  * @param PromotionActionInterface $action
  *
  * @return null|string
  */
 protected function getRegistryIdentifier($action)
 {
     if ($action instanceof PromotionActionInterface && null !== $action->getType()) {
         return $action->getType();
     }
     if (null !== $this->registryIdentifier) {
         return $this->registryIdentifier;
     }
     return null;
 }
 function it_reverts_all_actions_registered(ServiceRegistryInterface $registry, PromotionActionCommandInterface $action, PromotionSubjectInterface $subject, PromotionInterface $promotion, PromotionActionInterface $actionModel)
 {
     $configuration = [];
     $registry->get('test_action')->willReturn($action);
     $promotion->getActions()->willReturn([$actionModel]);
     $actionModel->getType()->willReturn('test_action');
     $actionModel->getConfiguration()->willReturn($configuration);
     $action->revert($subject, $configuration, $promotion)->shouldBeCalled();
     $subject->removePromotion($promotion)->shouldBeCalled();
     $this->revert($subject, $promotion);
 }
Пример #4
0
 /**
  * @param PromotionInterface $promotion
  * @param PromotionActionInterface $action
  * @param array $configuration
  * @param PromotionRuleInterface|null $rule
  */
 private function persistPromotion(PromotionInterface $promotion, PromotionActionInterface $action, array $configuration, PromotionRuleInterface $rule = null)
 {
     $configuration = array_merge($configuration, $action->getConfiguration());
     $action->setConfiguration($configuration);
     $promotion->addAction($action);
     if (null !== $rule) {
         $promotion->addRule($rule);
     }
     $this->objectManager->flush();
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function removeAction(PromotionActionInterface $action)
 {
     $action->setPromotion(null);
     $this->actions->removeElement($action);
 }