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