diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php index c6ef277be3..6804ded30d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerResolver.php @@ -70,17 +70,20 @@ class ControllerResolver extends BaseControllerResolver } } - list($class, $method) = explode('::', $controller, 2); + return parent::createController($controller); + } - if (!class_exists($class)) { - throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); - } + /** + * {@inheritdoc} + */ + protected function instantiateController($class) + { + $controller = parent::instantiateController($class); - $controller = $this->instantiateController($class); if ($controller instanceof ContainerAwareInterface) { $controller->setContainer($this->container); } - return array($controller, $method); + return $controller; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php index 4e804bf079..76a3489fe1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerResolverTest.php @@ -33,6 +33,18 @@ class ControllerResolverTest extends BaseControllerResolverTest $this->assertSame('testAction', $controller[1]); } + public function testGetControllerOnContainerAwareInvokable() + { + $resolver = $this->createControllerResolver(); + $request = Request::create('/'); + $request->attributes->set('_controller', 'Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController'); + + $controller = $resolver->getController($request); + + $this->assertInstanceOf('Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController', $controller); + $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $controller->getContainer()); + } + public function testGetControllerWithBundleNotation() { $shortName = 'FooBundle:Default:test'; @@ -161,4 +173,8 @@ class ContainerAwareController implements ContainerAwareInterface public function testAction() { } + + public function __invoke() + { + } }