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\Navigation; |
||
3 | |||
4 | use Redaxscript\Html; |
||
5 | use Redaxscript\Model; |
||
6 | use Redaxscript\Module; |
||
7 | use Redaxscript\Validator; |
||
8 | |||
9 | /** |
||
10 | * children class to create the comment navigation |
||
11 | * |
||
12 | * @since 3.3.0 |
||
13 | * |
||
14 | * @package Redaxscript |
||
15 | * @category Navigation |
||
16 | * @author Henry Ruhs |
||
17 | */ |
||
18 | |||
19 | class Comment extends NavigationAbstract |
||
20 | { |
||
21 | /** |
||
22 | * options of the navigation |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | |||
27 | protected $_optionArray = |
||
28 | [ |
||
29 | 'className' => |
||
30 | [ |
||
31 | 'list' => 'rs-list-comments' |
||
32 | ], |
||
33 | 'orderColumn' => 'rank' |
||
34 | ]; |
||
35 | |||
36 | /** |
||
37 | * render the view |
||
38 | * |
||
39 | * @since 3.3.0 |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | |||
44 | 2 | public function render() : string |
|
45 | { |
||
46 | 2 | $output = Module\Hook::trigger('navigationCommentStart'); |
|
47 | 2 | $outputItem = null; |
|
48 | 2 | $commentModel = new Model\Comment(); |
|
49 | 2 | $accessValidator = new Validator\Access(); |
|
50 | |||
51 | /* html element */ |
||
52 | |||
53 | 2 | $element = new Html\Element(); |
|
54 | $listElement = $element |
||
55 | 2 | ->copy() |
|
56 | 2 | ->init('ul', |
|
57 | [ |
||
58 | 2 | 'class' => $this->_optionArray['className']['list'] |
|
59 | ]); |
||
60 | 2 | $itemElement = $element->copy()->init('li'); |
|
61 | 2 | $linkElement = $element->copy()->init('a'); |
|
62 | 2 | $textElement = $element->copy()->init('span'); |
|
63 | |||
64 | /* query comments */ |
||
65 | |||
66 | $comments = $commentModel |
||
67 | 2 | ->query() |
|
68 | 2 | ->whereLanguageIs($this->_registry->get('language')) |
|
0 ignored issues
–
show
|
|||
69 | 2 | ->where('status', 1) |
|
70 | 2 | ->orderBySetting($this->_optionArray['orderColumn']) |
|
71 | 2 | ->limit($this->_optionArray['limit']) |
|
72 | 2 | ->findMany(); |
|
73 | |||
74 | /* collect item output */ |
||
75 | |||
76 | 2 | foreach ($comments as $value) |
|
77 | { |
||
78 | 2 | if ($accessValidator->validate($value->access, $this->_registry->get('myGroups'))) |
|
79 | { |
||
80 | $outputItem .= $itemElement |
||
81 | 2 | ->copy() |
|
82 | 2 | ->html($linkElement |
|
83 | 2 | ->copy() |
|
84 | 2 | ->attr( |
|
85 | [ |
||
86 | 2 | 'href' => $this->_registry->get('parameterRoute') . $commentModel->getRouteById($value->id) |
|
87 | ]) |
||
88 | 2 | ->text($value->author . $this->_language->get('colon') . ' ' . $value->text) |
|
89 | ); |
||
90 | } |
||
91 | } |
||
92 | |||
93 | /* collect output */ |
||
94 | |||
95 | 2 | $output .= $listElement->html($outputItem ? : $itemElement->html($textElement->text($this->_language->get('comment_no')))); |
|
96 | 2 | $output .= Module\Hook::trigger('navigationCommentEnd'); |
|
97 | 2 | return $output; |
|
98 | } |
||
99 | } |
||
100 |
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.