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

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