Total Complexity | 8 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
15 | class PageVoter extends AbstractVoter |
||
16 | { |
||
17 | /** |
||
18 | * @{inheritDoc} |
||
19 | */ |
||
20 | public function supportsClass($class) |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * @{inheritDoc} |
||
27 | */ |
||
28 | public function vote(TokenInterface $token, $object, array $attributes) |
||
29 | { |
||
30 | // check if class of this object is supported by this voter |
||
31 | if (!$this->supportsClass(get_class($object))) { |
||
32 | return VoterInterface::ACCESS_ABSTAIN; |
||
33 | } |
||
34 | |||
35 | foreach ($attributes as $attribute) { |
||
36 | if (!$this->supportsAttribute($attribute)) { |
||
37 | continue; |
||
38 | } |
||
39 | |||
40 | if ($this->isPublic($object)) { |
||
41 | return VoterInterface::ACCESS_GRANTED; |
||
42 | } |
||
43 | } |
||
44 | return VoterInterface::ACCESS_ABSTAIN; |
||
45 | } |
||
46 | |||
47 | |||
48 | /** |
||
49 | * Checks whether the given page is public. If not, it abstains from voting |
||
50 | * |
||
51 | * @param PageInterface $page |
||
52 | * @return bool |
||
53 | */ |
||
54 | public function isPublic(PageInterface $page) |
||
57 | } |
||
58 | } |
||
59 |