vendor/symfony/framework-bundle/EventListener/ResolveControllerNameSubscriber.php line 35

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Bundle\FrameworkBundle\EventListener;
  11. use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser;
  12. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  13. use Symfony\Component\HttpKernel\Event\GetResponseEvent;
  14. use Symfony\Component\HttpKernel\KernelEvents;
  15. /**
  16.  * Guarantees that the _controller key is parsed into its final format.
  17.  *
  18.  * @author Ryan Weaver <ryan@knpuniversity.com>
  19.  *
  20.  * @deprecated since Symfony 4.1
  21.  */
  22. class ResolveControllerNameSubscriber implements EventSubscriberInterface
  23. {
  24.     private $parser;
  25.     public function __construct(ControllerNameParser $parser)
  26.     {
  27.         $this->parser $parser;
  28.     }
  29.     public function onKernelRequest(GetResponseEvent $event)
  30.     {
  31.         $controller $event->getRequest()->attributes->get('_controller');
  32.         if (\is_string($controller) && false === strpos($controller'::') && === substr_count($controller':')) {
  33.             // controller in the a:b:c notation then
  34.             $event->getRequest()->attributes->set('_controller'$parsedNotation $this->parser->parse($controllerfalse));
  35.             @trigger_error(sprintf('Referencing controllers with %s is deprecated since Symfony 4.1, use "%s" instead.'$controller$parsedNotation), E_USER_DEPRECATED);
  36.         }
  37.     }
  38.     public static function getSubscribedEvents()
  39.     {
  40.         return [
  41.             KernelEvents::REQUEST => ['onKernelRequest'24],
  42.         ];
  43.     }
  44. }