From d2ad15798f6daac78ee4cf89a28d578de943be12 Mon Sep 17 00:00:00 2001 From: Matthieu Lempereur Date: Tue, 3 Sep 2024 19:18:40 +0200 Subject: [PATCH 1/2] fetch automatically is disabled in 7.1 --- doctrine.rst | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/doctrine.rst b/doctrine.rst index aba27545211..a7750854f55 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -677,27 +677,16 @@ will automatically fetch them:: { } - /** - * Perform a findOneBy() where the slug property matches {slug}. - */ - #[Route('/product/{slug}')] - public function showBySlug(Product $product): Response - { - } +Automatic fetching works if ``{id}`` is in your route, then this is used to +fetch by primary key via the ``find()`` method. -Automatic fetching works in these situations: - -* If ``{id}`` is in your route, then this is used to fetch by - primary key via the ``find()`` method. - -* The resolver will attempt to do a ``findOneBy()`` fetch by using - *all* of the wildcards in your route that are actually properties - on your entity (non-properties are ignored). +.. versionadded:: 7.1 -This behavior is enabled by default on all controllers. If you prefer, you can -restrict this feature to only work on route wildcards called ``id`` to look for -entities by primary key. To do so, set the option -``doctrine.orm.controller_resolver.auto_mapping`` to ``false``. + Prior to Symfony 7.1, automatic fetching was enabled on *all* of the + of the wildcards in your route that are actually properties on your entity. + This behavior is now disabled by default to only work on route wildcards + called ``id``. To do so, set the option + ``doctrine.orm.controller_resolver.auto_mapping`` to ``true``. When ``auto_mapping`` is disabled, you can configure the mapping explicitly for any controller argument with the ``MapEntity`` attribute. You can even control From 65a3c81512f5f209f3b30fb63958f76359687036 Mon Sep 17 00:00:00 2001 From: Matthieu Lempereur Date: Wed, 4 Sep 2024 06:37:05 +0200 Subject: [PATCH 2/2] lint --- doctrine.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doctrine.rst b/doctrine.rst index a7750854f55..63f19940d9f 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -685,7 +685,7 @@ fetch by primary key via the ``find()`` method. Prior to Symfony 7.1, automatic fetching was enabled on *all* of the of the wildcards in your route that are actually properties on your entity. This behavior is now disabled by default to only work on route wildcards - called ``id``. To do so, set the option + called ``id``. To do so, set the option ``doctrine.orm.controller_resolver.auto_mapping`` to ``true``. When ``auto_mapping`` is disabled, you can configure the mapping explicitly for