vendor/store.shopware.com/swagb2bplatform/SwagB2bPlatform/Routing/RouteScopeResolver.php line 21

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace SwagB2bPlatform\Routing;
  3. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  4. use Shopware\Core\Framework\Routing\KernelListenerPriorities;
  5. use Shopware\Core\PlatformRequest;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Symfony\Component\HttpKernel\Event\ControllerEvent;
  8. use Symfony\Component\HttpKernel\KernelEvents;
  9. class RouteScopeResolver implements EventSubscriberInterface
  10. {
  11.     public static function getSubscribedEvents()
  12.     {
  13.         return [
  14.             KernelEvents::CONTROLLER => ['resolveScope'KernelListenerPriorities::KERNEL_CONTROLLER_EVENT_PRIORITY_AUTH_VALIDATE_PRE],
  15.         ];
  16.     }
  17.     public function resolveScope(ControllerEvent $event): void
  18.     {
  19.         $request $event->getRequest();
  20.         if (!$request->attributes->get(RouteLoader::ROUTE_IS_B2B)) {
  21.             return;
  22.         }
  23.         $request->attributes->set(
  24.             PlatformRequest::ATTRIBUTE_ROUTE_SCOPE,
  25.             new RouteScope(['scopes' => ['storefront']])
  26.         );
  27.     }
  28. }