Where are default API Platform operations are stored?

痴心易碎 提交于 2019-12-11 16:42:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!