默认的API平台操作存储在哪里? [英] Where are default API Platform operations are stored?
本文介绍了默认的API平台操作存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道默认的API平台操作(CRUD方法)存储在哪里,以便可以在需要的地方调用它们.
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).
例如:
class GetResourceListAction
{
public function __invoke()
{
//Do my things here
//And finally call default operation which return collection
}
}
谢谢
推荐答案
As described in the documentation you can directly return your Collection and the API Platform operation will do the rest.
例如:
public function __invoke(Book $data): Book
{
$this->bookPublishingHandler->handle($data);
return $data;
}
这篇关于默认的API平台操作存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文