1 | <?php |
||
8 | abstract class Admin |
||
9 | { |
||
10 | /** |
||
11 | * Admin Section Icon. |
||
12 | * |
||
13 | * Font Awesome Defined Icon, eg 'user' = 'fa-user' |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $icon; |
||
18 | |||
19 | /** |
||
20 | * Title of Admin Section. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $title; |
||
25 | |||
26 | /** |
||
27 | * Plural Title of Admin Section. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $pluralTitle; |
||
32 | |||
33 | /** |
||
34 | * URL Prefix of Admin Section. |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $urlPrefix; |
||
39 | |||
40 | /** |
||
41 | * The Controller to be used by the Admin. |
||
42 | * |
||
43 | * This defaults to parent::getController() |
||
44 | * if it has been left undefined. |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $controller = \LaravelFlare\Flare\Http\Controllers\AdminController::class; |
||
49 | |||
50 | /** |
||
51 | * The Policy used for the Admin Authorization logic. |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $policy = '\LaravelFlare\Flare\Permissions\AdminPolicy'; |
||
56 | |||
57 | /** |
||
58 | * An array of subclasses of Admin |
||
59 | * which allows hierachy in a Module. |
||
60 | * |
||
61 | * @var array |
||
62 | */ |
||
63 | protected $subAdmin = []; |
||
64 | |||
65 | /** |
||
66 | * The Admin Default View. |
||
67 | * |
||
68 | * By Default this is the 404 page |
||
69 | * |
||
70 | * @var string |
||
71 | */ |
||
72 | protected $view = 'admin.404'; |
||
73 | |||
74 | /** |
||
75 | * Array of View Data to Render. |
||
76 | * |
||
77 | * @var array |
||
78 | */ |
||
79 | protected $viewData = []; |
||
80 | |||
81 | /** |
||
82 | * Class Suffix used for matching and removing term |
||
83 | * from user provided Admin sections. |
||
84 | * |
||
85 | * @var string |
||
86 | */ |
||
87 | const CLASS_SUFFIX = 'Admin'; |
||
88 | |||
89 | /** |
||
90 | * __construct. |
||
91 | */ |
||
92 | public function __construct() |
||
95 | |||
96 | /** |
||
97 | * Register the routes for this Admin Section. |
||
98 | * |
||
99 | * Default routes include, create:, read:, update:, delete: |
||
100 | * |
||
101 | * Also attempts to load in ModelAdminController |
||
102 | * based on the shortName of the class, for |
||
103 | * overloading and adding additional routes |
||
104 | * |
||
105 | * @param \Illuminate\Routing\Router $router |
||
106 | */ |
||
107 | public function registerRoutes(Router $router) |
||
116 | |||
117 | /** |
||
118 | * Register subRoutes for Defined Admin instances. |
||
119 | * |
||
120 | * @return |
||
121 | */ |
||
122 | public function registerSubRoutes() |
||
132 | |||
133 | /** |
||
134 | * Register an individual route. |
||
135 | * |
||
136 | * @param string $controller |
||
137 | * @param array $parameters |
||
138 | * |
||
139 | * @return |
||
140 | */ |
||
141 | public static function registerRoute($controller, $parameters = []) |
||
147 | |||
148 | /** |
||
149 | * Returns the Route Paramets. |
||
150 | * |
||
151 | * @return array |
||
152 | */ |
||
153 | public function routeParameters() |
||
160 | |||
161 | /** |
||
162 | * Returns the Requested Route Action as a |
||
163 | * string, namespace is returned by default. |
||
164 | * |
||
165 | * @param string $key |
||
166 | * |
||
167 | * @return string|void |
||
168 | */ |
||
169 | public static function getRequested($key = 'namespace') |
||
183 | |||
184 | /** |
||
185 | * Returns the Controller Class for the current Admin section. |
||
186 | * |
||
187 | * @return string |
||
188 | */ |
||
189 | public function getController() |
||
193 | |||
194 | /** |
||
195 | * Set the Controller Class for the current Admin section. |
||
196 | * |
||
197 | * @return string |
||
198 | */ |
||
199 | public function setController($controller = null) |
||
203 | |||
204 | /** |
||
205 | * Returns the Module Admin View. |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | public function getView() |
||
217 | |||
218 | /** |
||
219 | * Set the Module Admin View. |
||
220 | * |
||
221 | * @param string $view |
||
222 | */ |
||
223 | public function setView($view = null) |
||
227 | |||
228 | /** |
||
229 | * Returns the View Data. |
||
230 | * |
||
231 | * @return array |
||
232 | */ |
||
233 | public function getViewData() |
||
237 | |||
238 | /** |
||
239 | * Set the View Data. |
||
240 | * |
||
241 | * @param array $viewData |
||
242 | */ |
||
243 | public function setViewData($viewData = []) |
||
247 | |||
248 | /** |
||
249 | * Menu Items. |
||
250 | * |
||
251 | * @return array |
||
252 | */ |
||
253 | public function menuItems() |
||
257 | |||
258 | /** |
||
259 | * Icon of a Admin Section Class. |
||
260 | * |
||
261 | * @return string |
||
262 | */ |
||
263 | public function getIcon() |
||
264 | { |
||
265 | return $this->icon; |
||
266 | } |
||
267 | |||
268 | /** |
||
269 | * Set Icon of a Admin Section Class. |
||
270 | * |
||
271 | * @param string $icon |
||
272 | */ |
||
273 | public function setIcon($icon = null) |
||
274 | { |
||
275 | $this->icon = $icon; |
||
276 | } |
||
277 | |||
278 | /** |
||
279 | * Shortname of a Admin Section Class. |
||
280 | * |
||
281 | * @return string |
||
282 | */ |
||
283 | public static function shortName() |
||
284 | { |
||
285 | return (new \ReflectionClass(new static()))->getShortName(); |
||
286 | } |
||
287 | |||
288 | /** |
||
289 | * Title of a Admin Section Class. |
||
290 | * |
||
291 | * @return string |
||
292 | */ |
||
293 | public function getTitle() |
||
301 | |||
302 | /** |
||
303 | * Set Title of a Admin Section Class. |
||
304 | * |
||
305 | * @param string $title |
||
306 | */ |
||
307 | public function setTitle($title = null) |
||
311 | |||
312 | /** |
||
313 | * Plural of the Admin Section Class Title. |
||
314 | * |
||
315 | * @return string |
||
316 | */ |
||
317 | public function getPluralTitle() |
||
325 | |||
326 | /** |
||
327 | * Set Plural Title. |
||
328 | * |
||
329 | * @param string $pluralTitle |
||
330 | */ |
||
331 | public function setPluralTitle($pluralTitle = null) |
||
335 | |||
336 | /** |
||
337 | * URL Prefix to a Admin Section Top Level Page. |
||
338 | * |
||
339 | * @return string |
||
340 | */ |
||
341 | public function urlPrefix() |
||
349 | |||
350 | /** |
||
351 | * URL to a Admin Top Level Page. |
||
352 | * |
||
353 | * @param string $path |
||
354 | * |
||
355 | * @return string |
||
356 | */ |
||
357 | public function url($path = '') |
||
361 | |||
362 | /** |
||
363 | * Relative URL to an Admin Top Level Page. |
||
364 | * |
||
365 | * @param string $path |
||
366 | * |
||
367 | * @return string |
||
368 | */ |
||
369 | public function relativeUrl($path = '') |
||
373 | |||
374 | /** |
||
375 | * Retrieves the Current Admin Route URL. |
||
376 | * |
||
377 | * @param string $path |
||
378 | * |
||
379 | * @return string |
||
380 | */ |
||
381 | public function currentUrl($path = '') |
||
385 | |||
386 | /** |
||
387 | * Retrieves the Current Admin Route URL. |
||
388 | * |
||
389 | * @param string $path |
||
390 | * |
||
391 | * @return string |
||
392 | */ |
||
393 | public function relativeCurrentUrl($path) |
||
397 | |||
398 | /** |
||
399 | * Handle dynamic static method calls into the Admin. |
||
400 | * |
||
401 | * @param string $method |
||
402 | * @param array $parameters |
||
403 | * |
||
404 | * @return mixed |
||
405 | */ |
||
406 | // public static function __callStatic($method, $parameters) |
||
407 | // { |
||
408 | // $instance = new static(); |
||
409 | |||
410 | // return call_user_func_array([$instance, $method], $parameters); |
||
411 | // } |
||
412 | } |
||
413 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.