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