|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* BB's Zend Framework 2 Components |
|
4
|
|
|
* |
|
5
|
|
|
* AdminModule |
|
6
|
|
|
* |
|
7
|
|
|
* @package [MyApplication] |
|
8
|
|
|
* @package BB's Zend Framework 2 Components |
|
9
|
|
|
* @package AdminModule |
|
10
|
|
|
* @author Björn Bartels <[email protected]> |
|
11
|
|
|
* @link https://gitlab.bjoernbartels.earth/groups/zf2 |
|
12
|
|
|
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 |
|
13
|
|
|
* @copyright copyright (c) 2016 Björn Bartels <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace Admin\View\Helper; |
|
17
|
|
|
|
|
18
|
|
|
use Zend\View\Helper\AbstractHelper; |
|
19
|
|
|
|
|
20
|
|
|
class Isallowed extends AbstractHelper |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var AuthenticationService |
|
|
|
|
|
|
24
|
|
|
*/ |
|
25
|
|
|
protected $authService; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* __invoke |
|
29
|
|
|
* |
|
30
|
|
|
* @access public |
|
31
|
|
|
* @return \ZfcUser\Entity\UserInterface |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __invoke( $resource ) |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* @var Zend\Permissions\Acl\Acl $acl |
|
37
|
|
|
**/ |
|
38
|
|
|
$acl = $this->view->navigation()->getAcl(); |
|
|
|
|
|
|
39
|
|
|
if (empty($resource) || !$acl->hasResource($resource) ) { |
|
40
|
|
|
return true; |
|
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
/** |
|
43
|
|
|
* @var \Admin\Entity\User $user |
|
44
|
|
|
**/ |
|
45
|
|
|
$user = $this->view->zfcUserIdentity(); // ->getIdentity(); |
|
|
|
|
|
|
46
|
|
|
if ($user) { // ($this->getAuthService()->hasIdentity()) { |
|
|
|
|
|
|
47
|
|
|
//$user = $this->getAuthService()->getIdentity(); |
|
48
|
|
|
$role = $user->getAclrole(); |
|
49
|
|
|
} else { |
|
50
|
|
|
$role = 'public'; |
|
51
|
|
|
} |
|
52
|
|
|
return ( $acl->isAllowed($role, $resource) ); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Get authService. |
|
57
|
|
|
* |
|
58
|
|
|
* @return AuthenticationService |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getAuthService() |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->authService; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Set authService. |
|
67
|
|
|
* |
|
68
|
|
|
* @param AuthenticationService $authService |
|
69
|
|
|
* @return \ZfcUser\View\Helper\ZfcUserIdentity |
|
70
|
|
|
*/ |
|
71
|
|
|
public function setAuthService(AuthenticationService $authService) |
|
72
|
|
|
{ |
|
73
|
|
|
$this->authService = $authService; |
|
74
|
|
|
return $this; |
|
|
|
|
|
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths