[FrameworkBundle] fixed actions helper (and allowed short notation in the resolver)
This commit is contained in:
parent
2a8a9cc0a3
commit
c043c46116
@ -8,6 +8,7 @@ use Symfony\Components\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Components\HttpFoundation\Request;
|
||||
use Symfony\Components\EventDispatcher\Event;
|
||||
use Symfony\Components\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameConverter;
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony framework.
|
||||
@ -26,17 +27,20 @@ use Symfony\Components\DependencyInjection\ContainerInterface;
|
||||
class ControllerResolver extends BaseControllerResolver
|
||||
{
|
||||
protected $container;
|
||||
protected $converter;
|
||||
protected $esiSupport;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ContainerInterface $container A ContainerInterface instance
|
||||
* @param LoggerInterface $logger A LoggerInterface instance
|
||||
* @param ContainerInterface $container A ContainerInterface instance
|
||||
* @param ControllerNameConverter $converter A ControllerNameConverter instance
|
||||
* @param LoggerInterface $logger A LoggerInterface instance
|
||||
*/
|
||||
public function __construct(ContainerInterface $container, LoggerInterface $logger = null)
|
||||
public function __construct(ContainerInterface $container, ControllerNameConverter $converter, LoggerInterface $logger = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->converter = $converter;
|
||||
$this->esiSupport = $container->has('esi') && $container->getEsiService()->hasSurrogateEsiCapability($container->getRequestService());
|
||||
|
||||
parent::__construct($logger);
|
||||
@ -52,7 +56,8 @@ class ControllerResolver extends BaseControllerResolver
|
||||
protected function createController($controller)
|
||||
{
|
||||
if (false === strpos($controller, '::')) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller));
|
||||
// must be a controller in the a:b:c notation then
|
||||
$controller = $this->converter->fromShortNotation($controller);
|
||||
}
|
||||
|
||||
list($class, $method) = explode('::', $controller);
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
<service id="controller_resolver" class="%controller_resolver.class%">
|
||||
<argument type="service" id="service_container" />
|
||||
<argument type="service" id="controller_name_converter" />
|
||||
<argument type="service" id="logger" on-invalid="ignore" />
|
||||
</service>
|
||||
|
||||
|
Reference in New Issue
Block a user