src/Sylius/Bundle/CoreBundle/EventListener/OrderRecalculationListener.php line 34

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sylius package.
  4.  *
  5.  * (c) Paweł Jędrzejewski
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace Sylius\Bundle\CoreBundle\EventListener;
  12. use Sylius\Component\Core\Model\OrderInterface;
  13. use Sylius\Component\Order\Processor\OrderProcessorInterface;
  14. use Symfony\Component\EventDispatcher\GenericEvent;
  15. use Webmozart\Assert\Assert;
  16. final class OrderRecalculationListener
  17. {
  18.     /** @var OrderProcessorInterface */
  19.     private $orderProcessor;
  20.     public function __construct(OrderProcessorInterface $orderProcessor)
  21.     {
  22.         $this->orderProcessor $orderProcessor;
  23.     }
  24.     /**
  25.      * @throws \InvalidArgumentException
  26.      */
  27.     public function recalculateOrder(GenericEvent $event): void
  28.     {
  29.         $order $event->getSubject();
  30.         Assert::isInstanceOf($orderOrderInterface::class);
  31.         $this->orderProcessor->process($order);
  32.     }
  33. }