|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Rinvex\Menus\Presenters; |
|
6
|
|
|
|
|
7
|
|
|
use Rinvex\Menus\Models\MenuItem; |
|
8
|
|
|
|
|
9
|
|
|
class NavbarPresenter extends BasePresenter |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* {@inheritdoc} |
|
13
|
|
|
*/ |
|
14
|
|
|
public function getOpenTagWrapper(): string |
|
15
|
|
|
{ |
|
16
|
|
|
return '<ul class="nav navbar-nav">'; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* {@inheritdoc} |
|
21
|
|
|
*/ |
|
22
|
|
|
public function getCloseTagWrapper(): string |
|
23
|
|
|
{ |
|
24
|
|
|
return '</ul>'; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* {@inheritdoc} |
|
29
|
|
|
*/ |
|
30
|
|
|
public function getDividerWrapper(): string |
|
31
|
|
|
{ |
|
32
|
|
|
return '<li class="divider"></li>'; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* {@inheritdoc} |
|
37
|
|
|
*/ |
|
38
|
|
|
public function getHeaderWrapper(MenuItem $item): string |
|
39
|
|
|
{ |
|
40
|
|
|
return '<li class="dropdown-header">'.($item->icon ? '<i class="'.$item->icon.'"></i> ' : '').$item->title.'</li>'; |
|
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* {@inheritdoc} |
|
45
|
|
|
*/ |
|
46
|
|
|
public function getMenuWithoutDropdownWrapper(MenuItem $item): string |
|
47
|
|
|
{ |
|
48
|
|
|
return '<li class="'.($item->isActive() ? 'active' : '').'"> |
|
49
|
|
|
<a href="'.$item->getUrl().'" '.$item->getAttributes().'> |
|
50
|
|
|
'.($item->icon ? '<i class="'.$item->icon.'"></i>' : '').' |
|
|
|
|
|
|
51
|
|
|
'.$item->title.' |
|
|
|
|
|
|
52
|
|
|
</a> |
|
53
|
|
|
</li>'; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* {@inheritdoc} |
|
58
|
|
|
*/ |
|
59
|
|
|
public function getMenuWithDropDownWrapper(MenuItem $item, bool $specialSidebar = false): string |
|
60
|
|
|
{ |
|
61
|
|
|
return $specialSidebar |
|
62
|
|
|
? $this->getHeaderWrapper($item).$this->getChildMenuItems($item) |
|
63
|
|
|
: '<li class="dropdown'.($item->hasActiveOnChild() ? ' active' : '').'"> |
|
64
|
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> |
|
65
|
|
|
'.($item->icon ? '<i class="'.$item->icon.'"></i>' : '').' |
|
|
|
|
|
|
66
|
|
|
'.$item->title.'<strong class="caret"></strong> |
|
|
|
|
|
|
67
|
|
|
</a> |
|
68
|
|
|
<ul class="dropdown-menu"> |
|
69
|
|
|
'.$this->getChildMenuItems($item).' |
|
70
|
|
|
</ul> |
|
71
|
|
|
</li>'; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Get multilevel menu wrapper. |
|
76
|
|
|
* |
|
77
|
|
|
* @param \Rinvex\Menus\Models\MenuItem $item |
|
78
|
|
|
* |
|
79
|
|
|
* @return string` |
|
|
|
|
|
|
80
|
|
|
*/ |
|
81
|
|
|
public function getMultiLevelDropdownWrapper(MenuItem $item): string |
|
82
|
|
|
{ |
|
83
|
|
|
return '<li class="dropdown'.($item->hasActiveOnChild() ? ' active' : '').'"> |
|
84
|
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> |
|
85
|
|
|
'.($item->icon ? '<i class="'.$item->icon.'"></i>' : '').' |
|
|
|
|
|
|
86
|
|
|
'.$item->title.'<strong class="caret pull-right caret-right"></strong> |
|
|
|
|
|
|
87
|
|
|
</a> |
|
88
|
|
|
<ul class="dropdown-menu"> |
|
89
|
|
|
'.$this->getChildMenuItems($item).' |
|
90
|
|
|
</ul> |
|
91
|
|
|
</li>'; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
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@propertyannotation 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.