1 | <?php namespace Arcanesoft\Sidebar; |
||
13 | class Manager implements ManagerContract |
||
14 | { |
||
15 | /* ----------------------------------------------------------------- |
||
16 | | Properties |
||
17 | | ----------------------------------------------------------------- |
||
18 | */ |
||
19 | /** |
||
20 | * The view name. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $view = ''; |
||
25 | |||
26 | /** |
||
27 | * The current name. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $currentName; |
||
32 | |||
33 | /** |
||
34 | * The sidebar items collection. |
||
35 | * |
||
36 | * @var \Arcanesoft\Sidebar\Entities\ItemCollection |
||
37 | */ |
||
38 | protected $items; |
||
39 | |||
40 | /** |
||
41 | * The authenticated user. |
||
42 | * |
||
43 | * @var \Arcanesoft\Contracts\Auth\Models\User |
||
44 | */ |
||
45 | protected $user; |
||
46 | |||
47 | /* ----------------------------------------------------------------- |
||
48 | | Constructor |
||
49 | | ----------------------------------------------------------------- |
||
50 | */ |
||
51 | /** |
||
52 | * Manager constructor. |
||
53 | */ |
||
54 | 6 | public function __construct() |
|
59 | |||
60 | /* ----------------------------------------------------------------- |
||
61 | | Getters & Setters |
||
62 | | ----------------------------------------------------------------- |
||
63 | */ |
||
64 | /** |
||
65 | * Set the view name. |
||
66 | * |
||
67 | * @param string $view |
||
68 | * |
||
69 | * @return self |
||
70 | */ |
||
71 | public function setView($view) |
||
78 | |||
79 | /** |
||
80 | * Get the current item name. |
||
81 | * |
||
82 | * @return string |
||
83 | */ |
||
84 | public function getCurrent() |
||
88 | |||
89 | /** |
||
90 | * Set the current item name. |
||
91 | * |
||
92 | * @param string $currentName |
||
93 | * |
||
94 | * @return $this |
||
95 | */ |
||
96 | public function setCurrent($currentName) |
||
102 | |||
103 | /** |
||
104 | * Get the sidebar items. |
||
105 | * |
||
106 | * @return \Arcanesoft\Sidebar\Entities\ItemCollection |
||
107 | */ |
||
108 | 6 | public function getItems() |
|
112 | |||
113 | /* ----------------------------------------------------------------- |
||
114 | | Main Methods |
||
115 | | ----------------------------------------------------------------- |
||
116 | */ |
||
117 | /** |
||
118 | * Add a routed item. |
||
119 | * |
||
120 | * @param string $name |
||
121 | * @param string $title |
||
122 | * @param string $route |
||
123 | * @param array $parameters |
||
124 | * @param string|null $icon |
||
125 | * |
||
126 | * @return self |
||
127 | */ |
||
128 | public function addRouteItem($name, $title, $route, array $parameters = [], $icon = null) |
||
132 | |||
133 | /** |
||
134 | * Add an item. |
||
135 | * |
||
136 | * @param string $name |
||
137 | * @param string $title |
||
138 | * @param string $url |
||
139 | * @param string|null $icon |
||
140 | * |
||
141 | * @return self |
||
142 | */ |
||
143 | 3 | public function addItem($name, $title, $url = '#', $icon = null) |
|
147 | |||
148 | /** |
||
149 | * Add an item from array. |
||
150 | * |
||
151 | * @param array $array |
||
152 | * |
||
153 | * @return self |
||
154 | */ |
||
155 | 3 | public function add(array $array) |
|
163 | |||
164 | /** |
||
165 | * Load items from multiple config keys. |
||
166 | * |
||
167 | * @param string $key |
||
168 | * |
||
169 | * @return self |
||
170 | */ |
||
171 | public function loadItemsFromConfig($key) |
||
179 | |||
180 | /** |
||
181 | * Load sidebar item from config file. |
||
182 | * |
||
183 | * @param string $key |
||
184 | * |
||
185 | * @return self |
||
186 | */ |
||
187 | public function loadItemFromConfig($key) |
||
198 | |||
199 | /** |
||
200 | * Render the sidebar. |
||
201 | * |
||
202 | * @param string|null $view |
||
203 | * |
||
204 | * @return string |
||
205 | */ |
||
206 | public function render($view = null) |
||
212 | |||
213 | /* ----------------------------------------------------------------- |
||
214 | | Check Methods |
||
215 | | ----------------------------------------------------------------- |
||
216 | */ |
||
217 | /** |
||
218 | * Check if the sidebar has items. |
||
219 | * |
||
220 | * @return bool |
||
221 | */ |
||
222 | 6 | public function hasItems() |
|
226 | |||
227 | /* ----------------------------------------------------------------- |
||
228 | | Other Methods |
||
229 | | ----------------------------------------------------------------- |
||
230 | */ |
||
231 | /** |
||
232 | * Sync the current name wih the sidebar items. |
||
233 | * |
||
234 | * @return self |
||
235 | */ |
||
236 | private function syncCurrentName() |
||
242 | |||
243 | /** |
||
244 | * Get the authenticated user. |
||
245 | */ |
||
246 | 6 | private function setAuthenticatedUser() |
|
252 | } |
||
253 |