vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/EventListener/OrderLocaleAssigner.php line 27

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\ResourceBundle\Event\ResourceControllerEvent;
  13. use Sylius\Component\Core\Model\OrderInterface;
  14. use Sylius\Component\Locale\Context\LocaleContextInterface;
  15. use Webmozart\Assert\Assert;
  16. final class OrderLocaleAssigner
  17. {
  18.     public function __construct(private LocaleContextInterface $localeContext)
  19.     {
  20.     }
  21.     public function assignLocale(ResourceControllerEvent $event): void
  22.     {
  23.         $order $event->getSubject();
  24.         /** @var OrderInterface $order */
  25.         Assert::isInstanceOf($orderOrderInterface::class);
  26.         $order->setLocaleCode($this->localeContext->getLocaleCode());
  27.     }
  28. }