diff --git a/core/lib/Drupal/Core/Controller/ControllerResolver.php b/core/lib/Drupal/Core/Controller/ControllerResolver.php index 7d39389..9ae9788 100644 --- a/core/lib/Drupal/Core/Controller/ControllerResolver.php +++ b/core/lib/Drupal/Core/Controller/ControllerResolver.php @@ -104,10 +104,16 @@ protected function createController($controller) { */ protected function doGetArguments(Request $request, $controller, array $parameters) { $arguments = parent::doGetArguments($request, $controller, $parameters); + + // The parameter converter overrides the raw request attributes with the + // upcasted objects. However, it keeps a backup copy of the original, raw + // values in a special request attribute ('_raw'). If a controller argument + // has a type hint, we pass it the upcasted object, otherwise we pass it + // the original, raw value. if ($request->attributes->has('_raw') && $raw = $request->attributes->get('_raw')->all()) { foreach ($parameters as $parameter) { // Use the raw value if a parameter has no typehint. - if (!$parameter->getClass()) { + if (!$parameter->getClass() && isset($raw[$parameter->name])) { $position = $parameter->getPosition(); $arguments[$position] = $raw[$parameter->name]; } diff --git a/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php b/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php index 50bf2bb..15197e4 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php @@ -61,7 +61,7 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, $image_style = NULL, $image_effect = NULL, Request $request = NULL) { + public function buildForm(array $form, array &$form_state, ImageStyle $image_style = NULL, $image_effect = NULL, Request $request = NULL) { $this->imageStyle = $image_style; $this->imageEffect = image_effect_load($image_effect, $this->imageStyle->id()); diff --git a/core/modules/system/tests/modules/paramconverter_test/lib/Drupal/paramconverter_test/TestControllers.php b/core/modules/system/tests/modules/paramconverter_test/lib/Drupal/paramconverter_test/TestControllers.php index d3060e6..cd9b578 100644 --- a/core/modules/system/tests/modules/paramconverter_test/lib/Drupal/paramconverter_test/TestControllers.php +++ b/core/modules/system/tests/modules/paramconverter_test/lib/Drupal/paramconverter_test/TestControllers.php @@ -8,21 +8,21 @@ namespace Drupal\paramconverter_test; use Drupal\Core\Entity\EntityInterface; -use Drupal\user\UserInterface; +use Drupal\node\NodeInterface; +use Symfony\Component\HttpFoundation\Request; /** * Controller routine for testing the paramconverter. */ class TestControllers { - public function testUserNodeFoo(UserInterface $user, $node, $foo) { - $retval = "user: " . (is_object($user) ? $user->label() : $user); - $retval .= ", node: " . (is_object($node) ? $node->label() : $node); - $retval .= ", foo: " . (is_object($foo) ? $foo->label() : $foo); - return $retval; + public function testUserNodeFoo(EntityInterface $user, NodeInterface $node, Request $request) { + $foo = $request->attributes->get('foo'); + $foo = is_object($foo) ? $foo->label() : $foo; + return "user: {$user->label()}, node: {$node->label()}, foo: $foo"; } - public function testNodeSetParent(EntityInterface $node, EntityInterface $parent) { - return "Setting '{$parent->title}' as parent of '{$node->title}'."; + public function testNodeSetParent(NodeInterface $node, NodeInterface $parent) { + return "Setting '{$parent->label()}' as parent of '{$node->label()}'."; } }