/** * {@inheritdoc} */ public function revert(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)) { $subject->removeItem($item); } } }
/** * {@inheritdoc} */ public function revert(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); $promotionItem->setImmutable(true); foreach ($subject->getItems() as $item) { if ($item->equals($promotionItem)) { $subject->removeItem($item); } } }