vendor/shopware/core/Framework/Routing/RouteParamsCleanupListener.php line 20

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Routing;
  3. use Shopware\Core\Framework\Log\Package;
  4. use Shopware\Core\PlatformRequest;
  5. use Symfony\Component\HttpKernel\Event\RequestEvent;
  6. #[Package('core')]
  7. class RouteParamsCleanupListener
  8. {
  9.     private const CLEANUP_PARAMETERS = [
  10.         PlatformRequest::ATTRIBUTE_ROUTE_SCOPE,
  11.         PlatformRequest::ATTRIBUTE_CAPTCHA,
  12.         PlatformRequest::ATTRIBUTE_LOGIN_REQUIRED,
  13.         PlatformRequest::ATTRIBUTE_LOGIN_REQUIRED_ALLOW_GUEST,
  14.         PlatformRequest::ATTRIBUTE_ACL,
  15.     ];
  16.     public function __invoke(RequestEvent $event): void
  17.     {
  18.         $routeParams $event->getRequest()->attributes->get('_route_params');
  19.         if ($routeParams) {
  20.             foreach (self::CLEANUP_PARAMETERS as $param) {
  21.                 if (isset($routeParams[$param])) {
  22.                     unset($routeParams[$param]);
  23.                 }
  24.             }
  25.         }
  26.         $event->getRequest()->attributes->set('_route_params'$routeParams);
  27.     }
  28. }