diff --git a/core/lib/Drupal/Core/ControllerResolver.php b/core/lib/Drupal/Core/ControllerResolver.php index 0019f165ad2..abb988964c5 100644 --- a/core/lib/Drupal/Core/ControllerResolver.php +++ b/core/lib/Drupal/Core/ControllerResolver.php @@ -60,5 +60,7 @@ class ControllerResolver extends BaseControllerResolver { if ($controller[0] instanceof ContainerAwareInterface) { $controller[0]->setContainer($this->container); } + + return $controller; } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/ControllerResolverTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/ControllerResolverTest.php new file mode 100644 index 00000000000..46ed2a3919c --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/ControllerResolverTest.php @@ -0,0 +1,43 @@ + 'Controller Resolver tests', + 'description' => 'Tests that the Drupal-extended ControllerResolver is functioning properly.', + 'group' => 'Routing', + ); + } + + /** + * Confirms that a container aware controller gets returned. + */ + function testContainerAware() { + $container = new Container(); + $resolver = new ControllerResolver($container); + + $request = Request::create('/some/path'); + $request->attributes->set('_controller', '\Drupal\system\Tests\Routing\MockController::run'); + + $controller = $resolver->getController($request); + + $this->assertTrue($controller[0] instanceof MockController, 'The correct controller object was returned.'); + } +} diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/MockController.php b/core/modules/system/lib/Drupal/system/Tests/Routing/MockController.php new file mode 100644 index 00000000000..fe09a7b8524 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/MockController.php @@ -0,0 +1,19 @@ +