/** * @param PromotionActionInterface $action * * @return array */ protected function getConfiguration($action) { if ($action instanceof PromotionActionInterface && null !== $action->getConfiguration()) { return $action->getConfiguration(); } return []; }
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); }
/** * @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(); }