These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\Admin\View\Helper; |
||
3 | |||
4 | use Redaxscript\Admin\View\ViewAbstract; |
||
5 | use Redaxscript\Html; |
||
6 | use Redaxscript\Module; |
||
7 | use Redaxscript\Validator; |
||
8 | use function array_key_exists; |
||
9 | use function array_replace_recursive; |
||
10 | |||
11 | /** |
||
12 | * helper class to create the admin panel |
||
13 | * |
||
14 | * @since 4.0.0 |
||
15 | * |
||
16 | * @package Redaxscript |
||
17 | * @category View |
||
18 | * @author Henry Ruhs |
||
19 | */ |
||
20 | |||
21 | class Panel extends ViewAbstract |
||
22 | { |
||
23 | /** |
||
24 | * options of the panel |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | |||
29 | protected $_optionArray = |
||
30 | [ |
||
31 | 'className' => |
||
32 | [ |
||
33 | 'list' => |
||
34 | [ |
||
35 | 'panel' => 'rs-admin-fn-dropdown rs-admin-list-panel', |
||
36 | 'content' => 'rs-admin-fn-content-panel rs-admin-list-panel-children', |
||
37 | 'access' => 'rs-admin-fn-content-panel rs-admin-list-panel-children', |
||
38 | 'system' => 'rs-admin-fn-content-panel rs-admin-list-panel-children', |
||
39 | 'notification' => 'rs-admin-fn-content-panel rs-admin-list-panel-children rs-admin-list-notification' |
||
40 | ], |
||
41 | 'item' => |
||
42 | [ |
||
43 | 'content' => 'rs-admin-item-panel', |
||
44 | 'access' => 'rs-admin-item-panel', |
||
45 | 'system' => 'rs-admin-item-panel', |
||
46 | 'profile' => 'rs-admin-item-panel', |
||
47 | 'notification' => 'rs-admin-item-panel', |
||
48 | 'logout' => 'rs-admin-item-panel rs-admin-item-panel-logout' |
||
49 | ], |
||
50 | 'link' => |
||
51 | [ |
||
52 | 'view' => 'rs-admin-link-panel rs-admin-link-panel-view', |
||
53 | 'new' => 'rs-admin-link-panel rs-admin-link-panel-new', |
||
54 | 'system' => 'rs-admin-link-panel rs-admin-link-panel-system', |
||
55 | 'profile' => 'rs-admin-link-panel rs-admin-link-panel-profile', |
||
56 | 'logout' => 'rs-admin-link-panel rs-admin-link-panel-logout' |
||
57 | ], |
||
58 | 'label' => |
||
59 | [ |
||
60 | 'content' => 'rs-admin-fn-toggle-panel rs-admin-label-panel rs-admin-label-panel-content', |
||
61 | 'access' => 'rs-admin-fn-toggle-panel rs-admin-label-panel rs-admin-label-panel-access', |
||
62 | 'system' => 'rs-admin-fn-toggle-panel rs-admin-label-panel rs-admin-label-panel-system', |
||
63 | 'notification' => 'rs-admin-fn-toggle-panel rs-admin-label-panel rs-admin-label-panel-notification' |
||
64 | ], |
||
65 | 'note' => |
||
66 | [ |
||
67 | 'success' => 'rs-admin-is-success', |
||
68 | 'warning' => 'rs-admin-is-warning', |
||
69 | 'error' => 'rs-admin-is-error', |
||
70 | 'info' => 'rs-admin-is-info' |
||
71 | ], |
||
72 | 'text' => 'rs-admin-text-panel-group', |
||
73 | 'input' => 'rs-admin-fn-status-panel', |
||
74 | 'sup' => 'rs-admin-sup-panel-notification' |
||
75 | ] |
||
76 | ]; |
||
77 | |||
78 | /** |
||
79 | * init the class |
||
80 | * |
||
81 | * @since 4.0.0 |
||
82 | * |
||
83 | * @param array $optionArray options of the panel |
||
84 | */ |
||
85 | |||
86 | 8 | public function init(array $optionArray = []) : void |
|
87 | { |
||
88 | 8 | $this->_optionArray = array_replace_recursive($this->_optionArray, $optionArray); |
|
89 | 8 | } |
|
90 | |||
91 | /** |
||
92 | * render the view |
||
93 | * |
||
94 | * @since 4.0.0 |
||
95 | * |
||
96 | * @return string |
||
97 | */ |
||
98 | |||
99 | 8 | public function render() : string |
|
100 | { |
||
101 | 8 | $output = Module\Hook::trigger('adminPanelStart'); |
|
102 | 8 | $outputItem = null; |
|
103 | |||
104 | /* html element */ |
||
105 | |||
106 | 8 | $listElement = new Html\Element(); |
|
107 | 8 | $listElement->init('ul', |
|
108 | [ |
||
109 | 8 | 'class' => $this->_optionArray['className']['list']['panel'] |
|
110 | ]); |
||
111 | |||
112 | /* collect item output */ |
||
113 | |||
114 | 8 | if ($this->_hasPermission('contents')) |
|
115 | { |
||
116 | 2 | $outputItem .= $this->_renderContent(); |
|
117 | } |
||
118 | 8 | if ($this->_hasPermission('access')) |
|
119 | { |
||
120 | 2 | $outputItem .= $this->_renderAccess(); |
|
121 | } |
||
122 | 8 | if ($this->_hasPermission('system')) |
|
123 | { |
||
124 | 1 | $outputItem .= $this->_renderSystem(); |
|
125 | } |
||
126 | 8 | if ($this->_hasPermission('profile')) |
|
127 | { |
||
128 | 1 | $outputItem .= $this->_renderProfile(); |
|
129 | } |
||
130 | 8 | if ($this->_hasPermission('notification')) |
|
131 | { |
||
132 | 1 | $outputItem .= $this->_renderNotification(); |
|
133 | } |
||
134 | 8 | $outputItem .= $this->_renderLogout(); |
|
135 | |||
136 | /* collect output */ |
||
137 | |||
138 | 8 | $output .= $listElement->append($outputItem); |
|
139 | 8 | $output .= Module\Hook::trigger('adminPanelEnd'); |
|
140 | 8 | return $output; |
|
141 | } |
||
142 | |||
143 | /** |
||
144 | * has the permission |
||
145 | * |
||
146 | * @since 4.0.0 |
||
147 | * |
||
148 | * @param string $type |
||
149 | * |
||
150 | * @return bool |
||
151 | */ |
||
152 | |||
153 | 8 | protected function _hasPermission(string $type = null) : bool |
|
154 | { |
||
155 | 8 | $permissionArray = []; |
|
156 | 8 | $accessValidator = new Validator\Access(); |
|
157 | 8 | if ($this->_registry->get('categoriesEdit')) |
|
158 | { |
||
159 | 2 | $permissionArray['categories'] = $permissionArray['contents'] = true; |
|
160 | } |
||
161 | 8 | if ($this->_registry->get('articlesEdit')) |
|
162 | { |
||
163 | $permissionArray['articles'] = $permissionArray['contents'] = true; |
||
164 | } |
||
165 | 8 | if ($this->_registry->get('extrasEdit')) |
|
166 | { |
||
167 | $permissionArray['extras'] = $permissionArray['contents'] = true; |
||
168 | } |
||
169 | 8 | if ($this->_registry->get('commentsEdit')) |
|
170 | { |
||
171 | $permissionArray['comments'] = $permissionArray['contents'] = true; |
||
172 | } |
||
173 | 8 | if ($this->_registry->get('usersEdit')) |
|
174 | { |
||
175 | 2 | $permissionArray['users'] = $permissionArray['access'] = true; |
|
176 | } |
||
177 | 8 | if ($this->_registry->get('groupsEdit')) |
|
178 | { |
||
179 | $permissionArray['groups'] = $permissionArray['access'] = true; |
||
180 | } |
||
181 | 8 | if ($this->_registry->get('modulesEdit')) |
|
182 | { |
||
183 | 1 | $permissionArray['modules'] = $permissionArray['system'] = true; |
|
184 | } |
||
185 | 8 | if ($this->_registry->get('settingsEdit')) |
|
186 | { |
||
187 | 1 | $permissionArray['settings'] = $permissionArray['system'] = true; |
|
188 | } |
||
189 | 8 | if ($this->_registry->get('myId')) |
|
190 | { |
||
191 | 1 | $permissionArray['profile'] = true; |
|
192 | } |
||
193 | 8 | if ($accessValidator->validate(1, $this->_registry->get('myGroups'))) |
|
0 ignored issues
–
show
|
|||
194 | { |
||
195 | 1 | $permissionArray['notification'] = true; |
|
196 | } |
||
197 | 8 | return array_key_exists($type, $permissionArray); |
|
198 | } |
||
199 | |||
200 | /** |
||
201 | * render the content |
||
202 | * |
||
203 | * @since 4.0.0 |
||
204 | * |
||
205 | * @return string|null |
||
206 | */ |
||
207 | |||
208 | 2 | protected function _renderContent() : ?string |
|
209 | { |
||
210 | 2 | $output = null; |
|
211 | 2 | $parameterRoute = $this->_registry->get('parameterRoute'); |
|
212 | $contentArray = |
||
213 | [ |
||
214 | 2 | 'categories', |
|
215 | 'articles', |
||
216 | 'extras', |
||
217 | 'comments' |
||
218 | ]; |
||
219 | |||
220 | /* html element */ |
||
221 | |||
222 | 2 | $element = new Html\Element(); |
|
223 | $listElement = $element |
||
224 | 2 | ->copy() |
|
225 | 2 | ->init('ul', |
|
226 | [ |
||
227 | 2 | 'class' => $this->_optionArray['className']['list']['content'] |
|
228 | ]); |
||
229 | 2 | $itemElement = $element->copy()->init('li'); |
|
230 | 2 | $linkElement = $element->copy()->init('a'); |
|
231 | $textElement = $element |
||
232 | 2 | ->copy() |
|
233 | 2 | ->init('span', |
|
234 | [ |
||
235 | 2 | 'class' => $this->_optionArray['className']['text'] |
|
236 | ]); |
||
237 | $labelElement = $element |
||
238 | 2 | ->copy() |
|
239 | 2 | ->init('label', |
|
240 | [ |
||
241 | 2 | 'class' => $this->_optionArray['className']['label']['content'], |
|
242 | 'for' => self::class . '\Content' |
||
243 | ]) |
||
244 | 2 | ->text($this->_language->get('contents')); |
|
0 ignored issues
–
show
It seems like
$this->_language->get('contents') targeting Redaxscript\Language::get() can also be of type array ; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
245 | $inputElement = $element |
||
246 | 2 | ->copy() |
|
247 | 2 | ->init('input', |
|
248 | [ |
||
249 | 2 | 'id' => self::class . '\Content', |
|
250 | 2 | 'class' => $this->_optionArray['className']['input'], |
|
251 | 2 | 'type' => 'radio', |
|
252 | 'name' => self::class . '\Panel' |
||
253 | ]); |
||
254 | |||
255 | /* process contents */ |
||
256 | |||
257 | 2 | foreach ($contentArray as $type) |
|
258 | { |
||
259 | 2 | $tableNew = $this->_registry->get($type . 'New'); |
|
260 | 2 | if ($this->_hasPermission($type)) |
|
261 | { |
||
262 | 2 | $listElement->append( |
|
263 | $itemElement |
||
264 | 2 | ->copy() |
|
265 | 2 | ->html( |
|
266 | $textElement |
||
267 | 2 | ->copy() |
|
268 | 2 | ->append( |
|
269 | $linkElement |
||
270 | 2 | ->copy() |
|
271 | 2 | ->addClass($this->_optionArray['className']['link']['view']) |
|
272 | 2 | ->attr('href', $parameterRoute . 'admin/view/' . $type) |
|
273 | 2 | ->text($this->_language->get($type)) |
|
0 ignored issues
–
show
It seems like
$this->_language->get($type) targeting Redaxscript\Language::get() can also be of type array ; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
274 | ) |
||
275 | 2 | ->append($tableNew ? $linkElement |
|
0 ignored issues
–
show
It seems like
$tableNew ? $linkElement...age->get('new')) : null can also be of type object<Redaxscript\Html\Element> ; however, Redaxscript\Html\HtmlAbstract::append() does only seem to accept null|string , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.
Loading history...
|
|||
276 | 1 | ->copy() |
|
277 | 1 | ->addClass($this->_optionArray['className']['link']['new']) |
|
278 | 1 | ->attr('href', $parameterRoute . 'admin/new/' . $type) |
|
279 | 2 | ->text($this->_language->get('new')) : null |
|
0 ignored issues
–
show
It seems like
$this->_language->get('new') targeting Redaxscript\Language::get() can also be of type array ; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
280 | ) |
||
281 | ) |
||
282 | ); |
||
283 | } |
||
284 | } |
||
285 | |||
286 | /* collect output */ |
||
287 | |||
288 | $output .= $itemElement |
||
289 | 2 | ->copy() |
|
290 | 2 | ->addClass($this->_optionArray['className']['item']['content']) |
|
291 | 2 | ->html($inputElement . $labelElement . $listElement); |
|
292 | 2 | return $output; |
|
293 | } |
||
294 | |||
295 | /** |
||
296 | * render the access |
||
297 | * |
||
298 | * @since 4.0.0 |
||
299 | * |
||
300 | * @return string|null |
||
301 | */ |
||
302 | |||
303 | 2 | protected function _renderAccess() : ?string |
|
304 | { |
||
305 | 2 | $output = null; |
|
306 | 2 | $parameterRoute = $this->_registry->get('parameterRoute'); |
|
307 | $accessArray = |
||
308 | [ |
||
309 | 2 | 'users', |
|
310 | 'groups' |
||
311 | ]; |
||
312 | |||
313 | /* html element */ |
||
314 | |||
315 | 2 | $element = new Html\Element(); |
|
316 | $listElement = $element |
||
317 | 2 | ->copy() |
|
318 | 2 | ->init('ul', |
|
319 | [ |
||
320 | 2 | 'class' => $this->_optionArray['className']['list']['access'] |
|
321 | ]); |
||
322 | 2 | $itemElement = $element->copy()->init('li'); |
|
323 | 2 | $linkElement = $element->copy()->init('a'); |
|
324 | $textElement = $element |
||
325 | 2 | ->copy() |
|
326 | 2 | ->init('span', |
|
327 | [ |
||
328 | 2 | 'class' => $this->_optionArray['className']['text'] |
|
329 | ]); |
||
330 | $labelElement = $element |
||
331 | 2 | ->copy() |
|
332 | 2 | ->init('label', |
|
333 | [ |
||
334 | 2 | 'class' => $this->_optionArray['className']['label']['access'], |
|
335 | 'for' => self::class . '\Access' |
||
336 | ]) |
||
337 | 2 | ->text($this->_language->get('access')); |
|
0 ignored issues
–
show
It seems like
$this->_language->get('access') targeting Redaxscript\Language::get() can also be of type array ; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
338 | $inputElement = $element |
||
339 | 2 | ->copy() |
|
340 | 2 | ->init('input', |
|
341 | [ |
||
342 | 2 | 'id' => self::class . '\Access', |
|
343 | 2 | 'class' => $this->_optionArray['className']['input'], |
|
344 | 2 | 'type' => 'radio', |
|
345 | 'name' => self::class . '\Panel' |
||
346 | ]); |
||
347 | |||
348 | /* process access */ |
||
349 | |||
350 | 2 | foreach ($accessArray as $type) |
|
351 | { |
||
352 | 2 | $tableNew = $this->_registry->get($type . 'New'); |
|
353 | 2 | if ($this->_hasPermission($type)) |
|
354 | { |
||
355 | 2 | $listElement->append( |
|
356 | $itemElement |
||
357 | 2 | ->copy() |
|
358 | 2 | ->html( |
|
359 | $textElement |
||
360 | 2 | ->copy() |
|
361 | 2 | ->append( |
|
362 | $linkElement |
||
363 | 2 | ->copy() |
|
364 | 2 | ->addClass($this->_optionArray['className']['link']['view']) |
|
365 | 2 | ->attr('href', $parameterRoute . 'admin/view/' . $type) |
|
366 | 2 | ->text($this->_language->get($type)) |
|
0 ignored issues
–
show
It seems like
$this->_language->get($type) targeting Redaxscript\Language::get() can also be of type array ; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
367 | ) |
||
368 | 2 | ->append($tableNew ? $linkElement |
|
0 ignored issues
–
show
It seems like
$tableNew ? $linkElement...age->get('new')) : null can also be of type object<Redaxscript\Html\Element> ; however, Redaxscript\Html\HtmlAbstract::append() does only seem to accept null|string , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.
Loading history...
|
|||
369 | 1 | ->copy() |
|
370 | 1 | ->addClass($this->_optionArray['className']['link']['new']) |
|
371 | 1 | ->attr('href', $parameterRoute . 'admin/new/' . $type) |
|
372 | 2 | ->text($this->_language->get('new')) : null |
|
0 ignored issues
–
show
It seems like
$this->_language->get('new') targeting Redaxscript\Language::get() can also be of type array ; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
373 | ) |
||
374 | ) |
||
375 | ); |
||
376 | } |
||
377 | } |
||
378 | |||
379 | /* collect output */ |
||
380 | |||
381 | $output .= $itemElement |
||
382 | 2 | ->copy() |
|
383 | 2 | ->addClass($this->_optionArray['className']['item']['access']) |
|
384 | 2 | ->html($inputElement . $labelElement . $listElement); |
|
385 | 2 | return $output; |
|
386 | } |
||
387 | |||
388 | /** |
||
389 | * render the system |
||
390 | * |
||
391 | * @since 4.0.0 |
||
392 | * |
||
393 | * @return string|null |
||
394 | */ |
||
395 | |||
396 | 1 | protected function _renderSystem() : ?string |
|
397 | { |
||
398 | 1 | $output = null; |
|
399 | 1 | $parameterRoute = $this->_registry->get('parameterRoute'); |
|
400 | $systemArray = |
||
401 | [ |
||
402 | 1 | 'modules', |
|
403 | 'settings' |
||
404 | ]; |
||
405 | |||
406 | /* html element */ |
||
407 | |||
408 | 1 | $element = new Html\Element(); |
|
409 | $listElement = $element |
||
410 | 1 | ->copy() |
|
411 | 1 | ->init('ul', |
|
412 | [ |
||
413 | 1 | 'class' => $this->_optionArray['className']['list']['system'] |
|
414 | ]); |
||
415 | 1 | $itemElement = $element->copy()->init('li'); |
|
416 | $linkElement = $element |
||
417 | 1 | ->copy() |
|
418 | 1 | ->init('a', |
|
419 | [ |
||
420 | 1 | 'class' => $this->_optionArray['className']['link']['system'], |
|
421 | ]); |
||
422 | $labelElement = $element |
||
423 | 1 | ->copy() |
|
424 | 1 | ->init('label', |
|
425 | [ |
||
426 | 1 | 'class' => $this->_optionArray['className']['label']['system'], |
|
427 | 'for' => self::class . '\System' |
||
428 | ]) |
||
429 | 1 | ->text($this->_language->get('system')); |
|
0 ignored issues
–
show
It seems like
$this->_language->get('system') targeting Redaxscript\Language::get() can also be of type array ; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
430 | $inputElement = $element |
||
431 | 1 | ->copy() |
|
432 | 1 | ->init('input', |
|
433 | [ |
||
434 | 1 | 'id' => self::class . '\System', |
|
435 | 1 | 'class' => $this->_optionArray['className']['input'], |
|
436 | 1 | 'type' => 'radio', |
|
437 | 'name' => self::class . '\Panel' |
||
438 | ]); |
||
439 | |||
440 | /* process system */ |
||
441 | |||
442 | 1 | foreach ($systemArray as $type) |
|
443 | { |
||
444 | 1 | if ($this->_hasPermission($type)) |
|
445 | { |
||
446 | 1 | $listElement->append( |
|
447 | $itemElement |
||
448 | 1 | ->copy() |
|
449 | 1 | ->html( |
|
450 | $linkElement |
||
451 | 1 | ->copy() |
|
452 | 1 | ->attr('href', $type === 'settings' ? $parameterRoute . 'admin/edit/settings' : $parameterRoute . 'admin/view/' . $type) |
|
453 | 1 | ->text($this->_language->get($type)) |
|
0 ignored issues
–
show
It seems like
$this->_language->get($type) targeting Redaxscript\Language::get() can also be of type array ; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
454 | ) |
||
455 | ); |
||
456 | } |
||
457 | } |
||
458 | |||
459 | /* collect output */ |
||
460 | |||
461 | $output .= $itemElement |
||
462 | 1 | ->copy() |
|
463 | 1 | ->addClass($this->_optionArray['className']['item']['system']) |
|
464 | 1 | ->html($inputElement . $labelElement . $listElement); |
|
465 | 1 | return $output; |
|
466 | } |
||
467 | |||
468 | /** |
||
469 | * render the profile |
||
470 | * |
||
471 | * @since 4.0.0 |
||
472 | * |
||
473 | * @return string |
||
474 | */ |
||
475 | |||
476 | 1 | protected function _renderProfile() : string |
|
477 | { |
||
478 | 1 | $parameterRoute = $this->_registry->get('parameterRoute'); |
|
479 | 1 | $myId = $this->_registry->get('myId'); |
|
480 | |||
481 | /* html element */ |
||
482 | |||
483 | 1 | $element = new Html\Element(); |
|
484 | $itemElement = $element |
||
485 | 1 | ->copy() |
|
486 | 1 | ->init('li', |
|
487 | [ |
||
488 | 1 | 'class' => $this->_optionArray['className']['item']['profile'] |
|
489 | ]); |
||
490 | $linkElement = $element |
||
491 | 1 | ->copy() |
|
492 | 1 | ->init('a', |
|
493 | [ |
||
494 | 1 | 'href' => $parameterRoute . 'admin/edit/users/' . $myId, |
|
495 | 1 | 'class' => $this->_optionArray['className']['link']['profile'] |
|
496 | ]) |
||
497 | 1 | ->text($this->_language->get('profile')); |
|
0 ignored issues
–
show
It seems like
$this->_language->get('profile') targeting Redaxscript\Language::get() can also be of type array ; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
498 | |||
499 | /* collect item output */ |
||
500 | |||
501 | 1 | $output = $itemElement->html($linkElement); |
|
502 | 1 | return $output; |
|
503 | } |
||
504 | |||
505 | /** |
||
506 | * render the notification |
||
507 | * |
||
508 | * @since 4.0.0 |
||
509 | * |
||
510 | * @return string|null |
||
511 | */ |
||
512 | |||
513 | 1 | protected function _renderNotification() : ?string |
|
514 | { |
||
515 | 1 | $output = null; |
|
516 | 1 | $adminNotification = new Notification($this->_language); |
|
517 | 1 | $adminNotification->init( |
|
518 | [ |
||
519 | 'className' => |
||
520 | [ |
||
521 | 1 | 'list' => $this->_optionArray['className']['list']['notification'] |
|
522 | ] |
||
523 | ]); |
||
524 | 1 | $metaArray = $adminNotification->getMetaArray(); |
|
525 | |||
526 | /* html element */ |
||
527 | |||
528 | 1 | $element = new Html\Element(); |
|
529 | $itemElement = $element |
||
530 | 1 | ->copy() |
|
531 | 1 | ->init('li', |
|
532 | [ |
||
533 | 1 | 'class' => $this->_optionArray['className']['item']['notification'] |
|
534 | ]); |
||
535 | $labelElement = $element |
||
536 | 1 | ->copy() |
|
537 | 1 | ->init('label', |
|
538 | [ |
||
539 | 1 | 'class' => $this->_optionArray['className']['label']['notification'], |
|
540 | 'for' => self::class . '\Notification' |
||
541 | ]) |
||
542 | 1 | ->text($this->_language->get('notification')); |
|
0 ignored issues
–
show
It seems like
$this->_language->get('notification') targeting Redaxscript\Language::get() can also be of type array ; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
543 | $inputElement = $element |
||
544 | 1 | ->copy() |
|
545 | 1 | ->init('input', |
|
546 | [ |
||
547 | 1 | 'id' => self::class . '\Notification', |
|
548 | 1 | 'class' => $this->_optionArray['className']['input'], |
|
549 | 1 | 'type' => 'radio', |
|
550 | 'name' => self::class . '\Panel', |
||
551 | 1 | 'checked' => 'checked' |
|
552 | ]); |
||
553 | $supElement = $element |
||
554 | 1 | ->copy() |
|
555 | 1 | ->init('sup', |
|
556 | [ |
||
557 | 1 | 'class' => $this->_optionArray['className']['sup'] |
|
558 | ]) |
||
559 | 1 | ->text($metaArray['total']); |
|
560 | |||
561 | /* process meta */ |
||
562 | |||
563 | 1 | foreach ($metaArray as $key => $value) |
|
564 | { |
||
565 | 1 | $supElement->addClass($this->_optionArray['className']['note'][$key]); |
|
566 | } |
||
567 | 1 | $labelElement->append($supElement); |
|
568 | |||
569 | /* collect item output */ |
||
570 | |||
571 | 1 | if ($metaArray['total']) |
|
572 | { |
||
573 | 1 | $output = $itemElement->html($inputElement . $labelElement . $adminNotification->render()); |
|
574 | } |
||
575 | 1 | return $output; |
|
576 | } |
||
577 | |||
578 | /** |
||
579 | * render the logout |
||
580 | * |
||
581 | * @since 4.0.0 |
||
582 | * |
||
583 | * @return string |
||
584 | */ |
||
585 | |||
586 | 8 | protected function _renderLogout() : string |
|
587 | { |
||
588 | 8 | $parameterRoute = $this->_registry->get('parameterRoute'); |
|
589 | |||
590 | /* html element */ |
||
591 | |||
592 | 8 | $element = new Html\Element(); |
|
593 | $itemElement = $element |
||
594 | 8 | ->copy() |
|
595 | 8 | ->init('li', |
|
596 | [ |
||
597 | 8 | 'class' => $this->_optionArray['className']['item']['logout'] |
|
598 | ]); |
||
599 | $linkElement = $element |
||
600 | 8 | ->copy() |
|
601 | 8 | ->init('a', |
|
602 | [ |
||
603 | 8 | 'href' => $parameterRoute . 'logout', |
|
604 | 8 | 'class' => $this->_optionArray['className']['link']['logout'] |
|
605 | ]) |
||
606 | 8 | ->text($this->_language->get('logout')); |
|
0 ignored issues
–
show
It seems like
$this->_language->get('logout') targeting Redaxscript\Language::get() can also be of type array ; however, Redaxscript\Html\Element::text() does only seem to accept string|integer|null , maybe add an additional type check?
This check looks at variables that are passed out again to other methods. If the outgoing method call has stricter type requirements than the method itself, an issue is raised. An additional type check may prevent trouble.
Loading history...
|
|||
607 | |||
608 | /* collect item output */ |
||
609 | |||
610 | 8 | $output = $itemElement->html($linkElement); |
|
611 | 8 | return $output; |
|
612 | } |
||
613 | } |
||
614 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.