Skip to content

Commit 6608635

Browse files
authored
fix: clarify __invoke distinction (#1358)
1 parent 1081cb4 commit 6608635

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/controllers.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ This action will be automatically registered as a service (the service name is t
6868
API Platform automatically retrieves the appropriate PHP entity using the data provider then deserializes user data in it,
6969
and for `POST` and `PUT` requests updates the entity with data provided by the user.
7070

71-
**Warning: the `__invoke()` method parameter [MUST be called `$data`](https://symfony.com/doc/current/components/http_kernel.html#getting-the-controller-arguments)**, otherwise, it will not be filled correctly!
71+
**Warning: when using `POST` or `PUT`, the `__invoke()` method parameter [MUST be called `$data`](https://symfony.com/doc/current/components/http_kernel.html#getting-the-controller-arguments)**, otherwise, it will not be filled correctly!
72+
When using `GET`, the `__invoke()` method parameter should be called the same as the entity identifier. So for the path `/user/{uuid}/bookmarks`, you must use `__invoke($uuid)`.
7273

7374
Services (`$bookPublishingHandler` here) are automatically injected thanks to the autowiring feature. You can type-hint any service
7475
you need and it will be autowired too.

0 commit comments

Comments
 (0)