I use Symfony5
with ApiPlaform
I'm stuck on a litlle issue but I can't find any materials to get me through it
So, I have an entity open to the API from which I want to recover a list of
Naturally I set up collectionOperations
like so :
* collectionOperations={
* "get"={
* "mehtod"="GET",
* "security"="is_granted('LIST', object)",
* "normalization_context"={"groups"={"user:list"}},
* }
* },
And check inside my voter on the supports
method like that :
protected function supports($attribute, $subject): bool
{
return parent::supports($attribute, $subject)
&& (
$subject instanceof User
|| $this->arrayOf($subject, User::class)
);
}
I thought the arrayOf
condition would check for list of object, but I receive a pagination object, and therefore can only check if it's a pagination object, which could create issues with my other voters.
And anyway just return my a Paginator
object in the voteOnAttribute
method (already tried)
So my question is, is there a way to check for authorization on list of object by sending the object from the annotations to the voter ?
Thanks !
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…