The documentation has an example for the item Operation (https://api-platform.com/docs/core/operations#creating-custom-operations-and-controllers). How to do the same for collection operations? That's what's done, but it does not work.
// src/AppBundle/Entity/Book.php
* @ApiResource(collectionOperations={
* "get",
* "special"={"route_name"="book_special"}
* })
class Book
{
...
}
routing:
book_special:
path: '/books/special'
methods: ['POST']
defaults:
_controller: 'AppBundle:Book:special'
_api_resource_class: 'AppBundle\Entity\Book'
_api_collection_operation_name: 'special'
And Controller:
class BookController extends Controller
{
public function specialAction(Book $book, Request $request)
{
//in the variable $book there is nothing
//in the variable $request there is nothing
return $book;
}
}
How in the controller to receive data api request?