1 | <?php |
||
19 | class UserHelper extends Base |
||
20 | { |
||
21 | /** |
||
22 | * Return true if the logged user as unread notifications. |
||
23 | * |
||
24 | * @return bool |
||
25 | */ |
||
26 | public function hasNotifications() |
||
30 | |||
31 | /** |
||
32 | * Get initials from a user. |
||
33 | * |
||
34 | * @param string $name |
||
35 | * |
||
36 | * @return string |
||
37 | */ |
||
38 | public function getInitials($name) |
||
48 | |||
49 | /** |
||
50 | * Return the user full name. |
||
51 | * |
||
52 | * @param array $user User properties |
||
53 | * |
||
54 | * @return string |
||
55 | */ |
||
56 | public function getFullname(array $user = []) |
||
62 | |||
63 | /** |
||
64 | * Get user id. |
||
65 | * |
||
66 | * @return int |
||
67 | */ |
||
68 | public function getId() |
||
72 | |||
73 | /** |
||
74 | * Check if the given user_id is the connected user. |
||
75 | * |
||
76 | * @param int $user_id User id |
||
77 | * |
||
78 | * @return bool |
||
79 | */ |
||
80 | public function isCurrentUser($user_id) |
||
84 | |||
85 | /** |
||
86 | * Return if the logged user is admin. |
||
87 | * |
||
88 | * @return bool |
||
89 | */ |
||
90 | public function isAdmin() |
||
94 | |||
95 | /** |
||
96 | * Get role name. |
||
97 | * |
||
98 | * @param string $role |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | public function getRoleName($role = '') |
||
106 | |||
107 | /** |
||
108 | * Check application access. |
||
109 | * |
||
110 | * @param string $controller |
||
111 | * @param string $action |
||
112 | * |
||
113 | * @return bool |
||
114 | */ |
||
115 | public function hasAccess($controller, $action, $plugin = '') |
||
116 | { |
||
117 | if (!$this->userSession->isLogged()) { |
||
118 | return false; |
||
119 | } |
||
120 | |||
121 | $key = 'app_access:'.$controller.$action; |
||
122 | $result = $this->memoryCache->get($key); |
||
123 | |||
124 | if ($result === null) { |
||
125 | $result = $this->applicationAuthorization->isAllowed($controller, $action, $this->userSession->getRole(), $plugin); |
||
126 | $this->memoryCache->set($key, $result); |
||
127 | } |
||
128 | |||
129 | return $result; |
||
130 | } |
||
131 | |||
132 | /** |
||
133 | * Check project access. |
||
134 | * |
||
135 | * @param string $controller |
||
136 | * @param string $action |
||
137 | * @param int $project_id |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | public function hasProjectAccess($controller, $action, $project_id) |
||
153 | |||
154 | /** |
||
155 | * Check if a user is stargazer. |
||
156 | * |
||
157 | * @param int $project_id |
||
158 | * @param int $user_id |
||
159 | * |
||
160 | * @return bool |
||
161 | */ |
||
162 | public function isStargazer($project_id, $user_id) |
||
166 | } |
||
167 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.