Total Complexity | 5 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Coverage | 30% |
Changes | 0 |
1 | <?php |
||
18 | class PageViewValidation implements ViewValidationInterface |
||
19 | { |
||
20 | /** @var null|AuthorizationCheckerInterface */ |
||
21 | protected $auth; |
||
22 | |||
23 | /** |
||
24 | * PageViewValidation constructor. |
||
25 | * |
||
26 | * @param AuthorizationCheckerInterface|null $auth |
||
27 | */ |
||
28 | 3 | public function __construct(AuthorizationCheckerInterface $auth = null) |
|
31 | 3 | } |
|
32 | |||
33 | /** |
||
34 | * Similar to PageController it will return true when auth === null |
||
35 | * |
||
36 | * @param PageInterface $page |
||
37 | * @return bool |
||
38 | */ |
||
39 | protected function isAllowed(PageInterface $page) |
||
40 | { |
||
41 | if (null !== $this->auth) { |
||
42 | return $this->auth->isGranted('VIEW', $page); |
||
43 | } |
||
44 | return true; |
||
45 | } |
||
46 | |||
47 | |||
48 | /** |
||
49 | * @{inheritDoc} |
||
50 | */ |
||
51 | public function validate(PageInterface $page) |
||
55 | } |
||
56 | } |
||
58 |