Symfony 的 API 平台允许您使用 Voters 来授予或拒绝访问您的资源,如他们的文档中所述。
但是,所有示例都使用魔术值,我宁愿为此使用类常量。前任。
/**
* @ApiResource(
* itemOperations={
* "put"={"security"="is_granted(UserVoter::USER_EDIT, object)"},
* }
* )
*/
我已经尝试使用UserVoter
该类的“use”语句App\Security\Voter\UserVoter::USER_EDIT
以及 escaped App\\Security\\Voter\\UserVoter::USER_EDIT
,但是 API 平台没有接受任何内容
问题:如何在 API 平台中使用具有安全性的类常量?