0

Is it normal when supports() returns false, it results Access Denied? According the Doc, Voter should end-up on supports so I assume an access should be granted.

Voter::supports($attribute, $subject)

When isGranted() (or denyAccessUnlessGranted()) is called, the first argument is passed here as $attribute (e.g. ROLE_USER, edit) and the second argument (if any) is passed as $subject (e.g. null, a Post object). Your job is to determine if your voter should vote on the attribute/subject combination. If you return true, voteOnAttribute() will be called. Otherwise, your voter is done: some other voter should process this. In this example, you return true if the attribute is view or edit and if the object is a Post instance.

Roman Newaza
  • 11,405
  • 11
  • 58
  • 89
  • 1
    You get access denied when no voter grants access. – Mike Doe Feb 05 '19 at 19:42
  • So you mean, if there is `denyAccessUnlessGranted('something', $foo);` and a `Voter::supports()` returns `false`, `Access Denied` is expected because nothing is granting an access. I see. Thanks a lot! – Roman Newaza Feb 06 '19 at 09:29
  • 2
    It has nothing to do with the `Voter::supports()`. You get access denied because access hasn't been granted to you by any voter. Nothing more nothing less. – Mike Doe Feb 06 '19 at 10:29

0 Answers0