默认 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
}
}
谢谢
推荐答案
如文档 您可以直接返回您的集合,API 平台操作将完成剩下的工作.
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屋!
查看全文