Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function execute(PromotionSubjectInterface $subject, array $configuration, PromotionInterface $promotion)
 {
     if ($subject instanceof OrderItemInterface) {
         return;
     }
     if (!$subject instanceof OrderInterface) {
         throw new UnexpectedTypeException($subject, 'Sylius\\Component\\Order\\Model\\OrderInterface');
     }
     $promotionItem = $this->createItem($configuration);
     foreach ($subject->getItems() as $item) {
         if ($item->equals($promotionItem)) {
             return;
         }
     }
     $subject->addItem($promotionItem);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function execute(PromotionSubjectInterface $subject, array $configuration, PromotionInterface $promotion)
 {
     if ($subject instanceof OrderItemInterface) {
         return;
     }
     if (!$subject instanceof OrderInterface) {
         throw new UnexpectedTypeException($subject, OrderInterface::class);
     }
     $promotionItem = $this->createItem($configuration);
     foreach ($subject->getItems() as $item) {
         if ($item->equals($promotionItem)) {
             return;
         }
     }
     $promotionItem->setImmutable(true);
     $subject->addItem($promotionItem);
 }