存储默认API平台操作在哪里?

问题描述 投票:0回答:1

我想知道默认的API平台操作(CRUD方法)存储在哪里,以便我可以在任何需要的地方调用它们。

我需要它,因为当我定义自定义操作时,我想调用它们(默认操作),这样我就不需要重写代码(比如,获取资源集合)。

例如:

class GetResourceListAction
{
    public function __invoke()
    {
        //Do my things here

        //And finally call default operation which return collection
    }    
}

谢谢

php api symfony platform api-platform.com
1个回答
1
投票

documentation中所述,您可以直接返回您的Collection,其余的API平台操作将完成。

例如:

    public function __invoke(Book $data): Book
    {
        $this->bookPublishingHandler->handle($data);

        return $data;
    }
© www.soinside.com 2019 - 2024. All rights reserved.