1
|
|
|
<?php namespace Mascame\Artificer; |
2
|
|
|
|
3
|
|
|
use \App; |
4
|
|
|
use Mascame\Artificer\Http\Controllers\BaseModelController; |
5
|
|
|
use Mascame\Artificer\Model\Model; |
6
|
|
|
|
7
|
|
|
class Artificer |
8
|
|
|
{ |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Returns the current user's action. |
12
|
|
|
* |
13
|
|
|
* @return null|string list, edit, create, show |
14
|
|
|
*/ |
15
|
|
|
public static function getCurrentAction() |
16
|
|
|
{ |
17
|
|
|
switch (\Route::currentRouteName()) { |
18
|
|
|
case 'admin.model.create': |
19
|
|
|
return 'create'; |
20
|
|
|
case 'admin.model.edit': |
21
|
|
|
return 'edit'; |
22
|
|
|
case 'admin.model.show': |
23
|
|
|
return 'show'; |
24
|
|
|
case 'admin.model.all': |
25
|
|
|
case 'admin.model.filter': |
26
|
|
|
return 'list'; |
27
|
|
|
default: |
28
|
|
|
return null; |
29
|
|
|
} |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return Model |
34
|
|
|
*/ |
35
|
|
|
public static function getModel() |
36
|
|
|
{ |
37
|
|
|
return App::make('ArtificerModel'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return \Mascame\Artificer\Plugin\Manager |
42
|
|
|
*/ |
43
|
|
|
public static function pluginManager() |
44
|
|
|
{ |
45
|
|
|
return App::make('ArtificerPluginManager'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return \Mascame\Artificer\Widget\Manager |
50
|
|
|
*/ |
51
|
|
|
public static function widgetManager() |
52
|
|
|
{ |
53
|
|
|
return App::make('ArtificerWidgetManager'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
protected static function buildStyles($styles) { |
|
|
|
|
57
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public static function getCurrentModelId($items) |
61
|
|
|
{ |
62
|
|
|
return BaseModelController::getCurrentModelId($items); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
public static function addMenu($options) |
67
|
|
|
{ |
68
|
|
|
return config(['admin.menu' => array_merge(self::getMenu(), $options)]); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
protected static function getMenu() |
72
|
|
|
{ |
73
|
|
|
return config('admin.menu'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
// Todo is it used anywhere? |
77
|
|
|
// public static function store($filepath = null, $content, $overide = false) |
78
|
|
|
// { |
79
|
|
|
// if (!$filepath) { |
80
|
|
|
// $pathinfo = pathinfo($filepath); |
81
|
|
|
// $filepath = $pathinfo['dirname']; |
82
|
|
|
// } |
83
|
|
|
// |
84
|
|
|
// $path = explode('/', $filepath); |
85
|
|
|
// array_pop($path); |
86
|
|
|
// $path = join('/', $path); |
87
|
|
|
// |
88
|
|
|
// if (!file_exists($path)) { |
89
|
|
|
// \File::makeDirectory($path, 0777, true, true); |
90
|
|
|
// } |
91
|
|
|
// |
92
|
|
|
// if (!file_exists($filepath) || $overide) { |
93
|
|
|
// return \File::put($filepath, $content); |
94
|
|
|
// } |
95
|
|
|
// |
96
|
|
|
// return false; |
97
|
|
|
// } |
98
|
|
|
} |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.