vendor/symfony/framework-bundle/Controller/ControllerResolver.php line 60

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\Controller;
  11. use Psr\Log\LoggerInterface;
  12. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  13. use Symfony\Component\DependencyInjection\ContainerInterface;
  14. use Symfony\Component\HttpKernel\Controller\ContainerControllerResolver;
  15. /**
  16.  * @author Fabien Potencier <fabien@symfony.com>
  17.  */
  18. class ControllerResolver extends ContainerControllerResolver {
  19.     protected $parser;
  20.     public function __construct(ContainerInterface $containerControllerNameParser $parserLoggerInterface $logger null) {
  21.         $this->parser $parser;
  22.         parent::__construct($container$logger);
  23.     }
  24.     /**
  25.      * {@inheritdoc}
  26.      */
  27.     protected function createController($controller) {
  28.         if (false === strpos($controller'::') && === substr_count($controller':')) {
  29.             // controller in the a:b:c notation then
  30.             $deprecatedNotation $controller;
  31.             $controller $this->parser->parse($deprecatedNotationfalse);
  32.             @trigger_error(sprintf('Referencing controllers with %s is deprecated since Symfony 4.1. Use %s instead.'$deprecatedNotation$controller), E_USER_DEPRECATED);
  33.         }
  34.         return parent::createController($controller);
  35.     }
  36.     /**
  37.      * {@inheritdoc}
  38.      */
  39.     protected function instantiateController($class) {
  40.         return $this->configureController(parent::instantiateController($class), $class);
  41.     }
  42.     private function configureController($controllerstring $class) {
  43.         if ($controller instanceof ContainerAwareInterface) {
  44.             $controller->setContainer($this->container);
  45.         }
  46.         if ($controller instanceof AbstractController) {
  47.             if (null === $previousContainer $controller->setContainer($this->container)) {
  48.                 @trigger_error(sprintf('Auto-injection of the container for "%s" is deprecated since Symfony 4.2. Configure it as a service instead.'$class), E_USER_DEPRECATED);
  49.                 // To be uncommented on Symfony 5:
  50.                 //throw new \LogicException(sprintf('"%s" has no container set, did you forget to define it as a service subscriber?', $class));
  51.             } else {
  52.                 $controller->setContainer($previousContainer);
  53.             }
  54.         }
  55.         return $controller;
  56.     }
  57. }