diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php index 089908a..7e8edf7 100644 --- a/core/lib/Drupal/Core/CoreBundle.php +++ b/core/lib/Drupal/Core/CoreBundle.php @@ -96,8 +96,13 @@ public function build(ContainerBuilder $container) { ->addArgument(new Reference('paramconverter_manager')) ->addTag('kernel.event_subscriber'); $container->register('paramconverter.entity', 'Drupal\Core\ParamConverter\EntityConverter'); - $container->getDefinition('paramconverter_manager') - ->addMethodCall('addConverterService', array('paramconverter.entity', 'Drupal\node\Node')); + $paramconverter_manager = $container->getDefinition('paramconverter_manager'); + + $entity_info = entity_get_info(); + foreach ($entity_info as $entity_type => $info) { + $paramconverter_manager->addMethodCall('addConverterService', + array('paramconverter.entity', $info['entity class'])); + } $container->register('router_processor_subscriber', 'Drupal\Core\EventSubscriber\RouteProcessorSubscriber') ->addTag('kernel.event_subscriber'); diff --git a/core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php index 6854e32..c5d7359 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\Core\EventSubscriber\MParamConverterSubscriber. + * Definition of Drupal\Core\EventSubscriber\ParamConverterSubscriber. */ namespace Drupal\Core\EventSubscriber; diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/ParamConverterTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/ParamConverterTest.php index 5123a53..e3b79f1 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Routing/ParamConverterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/ParamConverterTest.php @@ -48,6 +48,12 @@ public function testCanRoute() { $this->drupalGet('router_test/test6/' . $node->id()); $this->assertRaw($title, 'The correct node title was found, and there were no fatal errors.'); + + // Trying upcasting with user entity to see if it works with enitities other than Node. + $user = $this->drupalCreateUser(); + $this->drupalGet('router_test/test5/' . $user->id()); + $this->assertRaw($user->name,'The correct username was found, and there were no fatal errors.'); + } } diff --git a/core/modules/system/tests/modules/router_test/lib/Drupal/router_test/TestControllers.php b/core/modules/system/tests/modules/router_test/lib/Drupal/router_test/TestControllers.php index 532a73a..86a8058 100644 --- a/core/modules/system/tests/modules/router_test/lib/Drupal/router_test/TestControllers.php +++ b/core/modules/system/tests/modules/router_test/lib/Drupal/router_test/TestControllers.php @@ -9,6 +9,7 @@ use Symfony\Component\HttpFoundation\Response; use Drupal\node\Node; +use Drupal\user\User; /** * Controller routines for testing the routing system. @@ -36,4 +37,8 @@ public function test6(Node $node) { // we get here. return $node->label(); } + + public function test5(User $user) { + return $user->name; + } + } diff --git a/core/modules/system/tests/modules/router_test/router_test.module b/core/modules/system/tests/modules/router_test/router_test.module index 621e447..7c60b0f 100644 --- a/core/modules/system/tests/modules/router_test/router_test.module +++ b/core/modules/system/tests/modules/router_test/router_test.module @@ -30,10 +30,16 @@ function router_test_route_info() { )); $collection->add('router_test_4', $route); + $route = new Route('router_test/test5/{user}', array( + '_controller' => '\Drupal\router_test\TestControllers::test5', + )); + $collection->add('router_test_5', $route); + $route = new Route('router_test/test6/{node}', array( '_controller' => '\Drupal\router_test\TestControllers::test6', )); $collection->add('router_test_6', $route); return $collection; }