custom/static-plugins/SamsonCustomer/src/Routing/ContextResolverListener.php line 55

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Samson\Routing;
  3. /***
  4.  *
  5.  * This file is part of the "SAMSON Shop" project.
  6.  *
  7.  * For the full copyright and license information, please read the
  8.  * LICENSE.txt file that was distributed with this source code.
  9.  *
  10.  *  (c) 2020
  11.  *
  12.  ***/
  13. use Shopware\Core\Framework\Routing\KernelListenerPriorities;
  14. use Shopware\Core\Framework\Routing\RequestContextResolverInterface;
  15. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  16. use Symfony\Component\HttpKernel\Event\ControllerEvent;
  17. use Symfony\Component\HttpKernel\KernelEvents;
  18. /**
  19.  * Class ContextResolverListener
  20.  * @package Samson\Api\Controller
  21.  * @author Artur Seitz <artur.seitz@dkd.de>
  22.  */
  23. class ContextResolverListener implements EventSubscriberInterface
  24. {
  25.     /** @var RequestContextResolverInterface */
  26.     protected $requestContextResolver;
  27.     /**
  28.      * ContextResolverListener constructor.
  29.      * @param RequestContextResolverInterface $requestContextResolver
  30.      */
  31.     public function __construct(
  32.         RequestContextResolverInterface $requestContextResolver
  33.     ) {
  34.         $this->requestContextResolver $requestContextResolver;
  35.     }
  36.     /** {@inheritDoc} */
  37.     public static function getSubscribedEvents(): array
  38.     {
  39.         return [
  40.             KernelEvents::CONTROLLER => [
  41.                 ['resolveContext'KernelListenerPriorities::KERNEL_CONTROLLER_EVENT_CONTEXT_RESOLVE],
  42.             ],
  43.         ];
  44.     }
  45.     /**
  46.      * KernelEvents::CONTROLLER event listener.
  47.      * @param ControllerEvent $event
  48.      */
  49.     public function resolveContext(ControllerEvent $event): void
  50.     {
  51.         $this->requestContextResolver->resolve($event->getRequest());
  52.     }
  53. }