src/Sylius/Bundle/ShopBundle/EventListener/OrderCustomerIpListener.php line 36

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\ShopBundle\EventListener;
  12. use Sylius\Bundle\CoreBundle\Assigner\IpAssignerInterface;
  13. use Sylius\Component\Core\Model\OrderInterface;
  14. use Symfony\Component\EventDispatcher\GenericEvent;
  15. use Symfony\Component\HttpFoundation\RequestStack;
  16. use Webmozart\Assert\Assert;
  17. final class OrderCustomerIpListener
  18. {
  19.     /** @var IpAssignerInterface */
  20.     private $ipAssigner;
  21.     /** @var RequestStack */
  22.     private $requestStack;
  23.     public function __construct(IpAssignerInterface $ipAssignerRequestStack $requestStack)
  24.     {
  25.         $this->ipAssigner $ipAssigner;
  26.         $this->requestStack $requestStack;
  27.     }
  28.     public function assignCustomerIpToOrder(GenericEvent $event): void
  29.     {
  30.         $subject $event->getSubject();
  31.         Assert::isInstanceOf($subjectOrderInterface::class);
  32.         $this->ipAssigner->assign($subject$this->requestStack->getMasterRequest());
  33.     }
  34. }