问题
I would like to know where are default API Platform operations (CRUD methods) are stored so that I can call them wherever I need.
I need it because when I define my custom operations, I want to call them (default operations) so that I don't need to rewrite the code (like, get a collection of resource).
For example:
class GetResourceListAction
{
public function __invoke()
{
//Do my things here
//And finally call default operation which return collection
}
}
Thank you
回答1:
As described in the documentation you can directly return your Collection and the API Platform operation will do the rest.
Ex :
public function __invoke(Book $data): Book
{
$this->bookPublishingHandler->handle($data);
return $data;
}
来源:https://stackoverflow.com/questions/55254473/where-are-default-api-platform-operations-are-stored