commit 628322125cc5d80954c87f51677e250bffede30c Author: Lee Rowlands Date: Sun Jul 28 14:28:39 2013 +1000 Pass diff --git a/core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php b/core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php index d8e5cd5..66534a3 100644 --- a/core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php +++ b/core/lib/Drupal/Core/Entity/Enhancer/EntityRouteEnhancer.php @@ -59,12 +59,14 @@ public function enhance(array $defaults, Request $request) { else { // The entity is not keyed by its entity_type. Attempt to find it // using a converter. - $route = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT); - $options = $route->getOptions(); - if (isset($options['converters'])) { - $flipped = array_flip($options['converters']); - if (isset($flipped[$entity_type]) && !empty($defaults[$flipped[$entity_type]])) { - $defaults['entity'] = $defaults[$flipped[$entity_type]]; + $route = $defaults[RouteObjectInterface::ROUTE_OBJECT]; + if ($route && is_object($route)) { + $options = $route->getOptions(); + if (isset($options['converters'])) { + $flipped = array_flip($options['converters']); + if (isset($flipped[$entity_type]) && !empty($defaults[$flipped[$entity_type]])) { + $defaults['entity'] = &$defaults[$flipped[$entity_type]]; + } } } } diff --git a/core/tests/Drupal/Tests/Core/Entity/Enhancer/EntityRouteEnhancerTest.php b/core/tests/Drupal/Tests/Core/Entity/Enhancer/EntityRouteEnhancerTest.php index 00bae1c..f6da78d 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Enhancer/EntityRouteEnhancerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Enhancer/EntityRouteEnhancerTest.php @@ -91,7 +91,7 @@ public function testEnhancer() { ->method('getOptions') ->will($this->returnValue($options)); - $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, $route); + $defaults[RouteObjectInterface::ROUTE_OBJECT] = $route; $defaults = $route_enhancer->enhance($defaults, $request); $this->assertEquals('controller.page:content', $defaults['_controller']); $this->assertEquals('\Drupal\Core\Entity\Controller\EntityViewController::view', $defaults['_content'], 'The entity view controller was not set.'); commit 5dfa334ea7e95b6ae5b359b344d6412891e9a59e Author: Lee Rowlands Date: Sun Jul 28 14:27:14 2013 +1000 Fail diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewControllerTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewControllerTest.php index 2363729..8c885ac 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewControllerTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewControllerTest.php @@ -58,6 +58,10 @@ function testEntityViewController() { $this->drupalGet('entity-test-render/' . $entity->id()); $this->assertRaw($entity->label()); $this->assertRaw('full'); + + $this->drupalGet('entity-test-render-converter/' . $entity->id()); + $this->assertRaw($entity->label()); + $this->assertRaw('full'); } } } diff --git a/core/modules/system/tests/modules/entity_test/entity_test.routing.yml b/core/modules/system/tests/modules/entity_test/entity_test.routing.yml index 08d247e..6cf2319 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.routing.yml +++ b/core/modules/system/tests/modules/entity_test/entity_test.routing.yml @@ -4,3 +4,13 @@ entity_test_render: _entity_view: 'entity_test_render.full' requirements: _access: 'TRUE' + +entity_test_render_options: + pattern: '/entity-test-render-converter/{foo}' + options: + converters: + foo: 'entity_test_render' + defaults: + _entity_view: 'entity_test_render.full' + requirements: + _access: 'TRUE'