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 article navigation |
||
11 | * |
||
12 | * @since 3.3.0 |
||
13 | * |
||
14 | * @package Redaxscript |
||
15 | * @category Navigation |
||
16 | * @author Henry Ruhs |
||
17 | */ |
||
18 | |||
19 | class Article 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-articles', |
||
32 | 'active' => 'rs-item-active' |
||
33 | ], |
||
34 | 'orderColumn' => 'rank' |
||
35 | ]; |
||
36 | |||
37 | /** |
||
38 | * render the view |
||
39 | * |
||
40 | * @since 3.3.0 |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | |||
45 | 3 | public function render() : string |
|
46 | { |
||
47 | 3 | $output = Module\Hook::trigger('navigationArticleStart'); |
|
48 | 3 | $outputItem = null; |
|
49 | 3 | $articleModel = new Model\Article(); |
|
50 | 3 | $accessValidator = new Validator\Access(); |
|
51 | |||
52 | /* html element */ |
||
53 | |||
54 | 3 | $element = new Html\Element(); |
|
55 | $listElement = $element |
||
56 | 3 | ->copy() |
|
57 | 3 | ->init('ul', |
|
58 | [ |
||
59 | 3 | 'class' => $this->_optionArray['className']['list'] |
|
60 | ]); |
||
61 | 3 | $itemElement = $element->copy()->init('li'); |
|
62 | 3 | $linkElement = $element->copy()->init('a'); |
|
63 | 3 | $textElement = $element->copy()->init('span'); |
|
64 | |||
65 | /* query articles */ |
||
66 | |||
67 | $articles = $articleModel |
||
68 | 3 | ->query() |
|
69 | 3 | ->whereLanguageIs($this->_registry->get('language')) |
|
0 ignored issues
–
show
|
|||
70 | 3 | ->where('status', 1) |
|
71 | 3 | ->orderBySetting($this->_optionArray['orderColumn']) |
|
72 | 3 | ->limit($this->_optionArray['limit']) |
|
73 | 3 | ->findMany(); |
|
74 | |||
75 | /* collect item output */ |
||
76 | |||
77 | 3 | foreach ($articles as $value) |
|
78 | { |
||
79 | 3 | if ($accessValidator->validate($value->access, $this->_registry->get('myGroups'))) |
|
80 | { |
||
81 | $outputItem .= $itemElement |
||
82 | 3 | ->copy() |
|
83 | 3 | ->addClass((int)$this->_registry->get('articleId') === (int)$value->id ? $this->_optionArray['className']['active'] : null) |
|
84 | 3 | ->html($linkElement |
|
85 | 3 | ->copy() |
|
86 | 3 | ->attr( |
|
87 | [ |
||
88 | 3 | 'href' => $this->_registry->get('parameterRoute') . $articleModel->getRouteById($value->id) |
|
89 | ]) |
||
90 | 3 | ->text($value->title) |
|
91 | ); |
||
92 | } |
||
93 | } |
||
94 | |||
95 | /* collect output */ |
||
96 | |||
97 | 3 | $output .= $listElement->html($outputItem ? : $itemElement->html($textElement->text($this->_language->get('article_no')))); |
|
98 | 3 | $output .= Module\Hook::trigger('navigationArticleEnd'); |
|
99 | 3 | return $output; |
|
100 | } |
||
101 | } |
||
102 |
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.