You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -65,7 +65,10 @@ This action will be automatically registered as a service (the service name is t
65
65
API Platform automatically retrieves the appropriate PHP entity using the data provider then deserializes user data in it,
66
66
and for `POST` and `PUT` requests updates the entity with data provided by the user.
67
67
68
-
**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!
68
+
The entity is retrieved in the `__invoke` method thanks to a dedicated argument resolver.
69
+
70
+
When using `GET`, the `__invoke()` method parameter will receive the identifier and should be called the same as the resource identifier.
71
+
So for the path `/user/{uuid}/bookmarks`, you must use `__invoke(string $uuid)`.
69
72
70
73
Services (`$bookPublishingHandler` here) are automatically injected thanks to the autowiring feature. You can type-hint any service
71
74
you need and it will be autowired too.
@@ -386,11 +389,11 @@ class CreateBookPublication
386
389
* }
387
390
* )
388
391
*/
389
-
public function __invoke(Book $data): Book
392
+
public function __invoke(Book $book): Book
390
393
{
391
-
$this->bookPublishingHandler->handle($data);
394
+
$this->bookPublishingHandler->handle($book);
392
395
393
-
return $data;
396
+
return $book;
394
397
}
395
398
}
396
399
```
@@ -412,9 +415,9 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
412
415
413
416
class BookController extends AbstractController
414
417
{
415
-
public function createPublication(Book $data, BookPublishingHandler $bookPublishingHandler): Book
418
+
public function createPublication(Book $book, BookPublishingHandler $bookPublishingHandler): Book
0 commit comments