From 070c9bb8781d956ba645442e1b71781a79e51044 Mon Sep 17 00:00:00 2001 From: Massimiliano Arione Date: Sun, 7 Mar 2021 11:20:51 +0100 Subject: [PATCH] add a warning about object as extra parameter in route --- routing.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/routing.rst b/routing.rst index 86defd2bafc..7c852af98da 100644 --- a/routing.rst +++ b/routing.rst @@ -1880,6 +1880,14 @@ use the ``generateUrl()`` helper:: // the 'blog' route only defines the 'page' parameter; the generated URL is: // /blog/2?category=Symfony +.. caution:: + + While objects are converted to string when used as placeholders, they are not + converted when used as extra parameters. So, if you're passing an object (e.g. an Uuid) + as value of an extra parameter, you need to explictly convert it to a string:: + + $this->generateUrl('blog', ['uuid' => (string) $entity->getUuid())] + If your controller does not extend from ``AbstractController``, you'll need to :ref:`fetch services in your controller ` and follow the instructions of the next section.