Completed
Push — dev ( 8e4a13...e9dbc4 )
by Marc
02:06
created

Artificer::assets()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace Mascame\Artificer;
2
3
use App;
4
use Mascame\Artificer\Extension\WidgetManager;
5
use Mascame\Artificer\Http\Controllers\BaseController;
6
use Mascame\Artificer\Http\Controllers\BaseModelController;
7
use Mascame\Artificer\Extension\PluginManager;
8
use Mascame\Artificer\Model\Model;
9
10
class Artificer
11
{
12
13
    public static $booted = false;
14
15
    public static function isBooted() {
16
        return self::$booted;
17
    }
18
19
    /**
20
     * Returns the current user's action.
21
     *
22
     * @return null|string
23
     */
24
    public static function getCurrentAction()
25
    {
26
        switch (\Route::currentRouteName()) {
27
            case 'admin.model.create':
28
                return 'create';
29
            case 'admin.model.edit':
30
                return 'edit';
31
            case 'admin.model.show':
32
                return 'show';
33
            case 'admin.model.all':
34
            case 'admin.model.filter':
35
                return 'list';
36
            default:
37
                return null;
38
        }
39
    }
40
41
    /**
42
     * @return Model
43
     */
44
    public static function getModel()
45
    {
46
        return App::make('ArtificerModel');
47
    }
48
49
    public static function assets()
50
    {
51
        return BaseController::assets();
52
    }
53
54
    public static function getCurrentModelId($items)
55
    {
56
        return BaseModelController::getCurrentModelId($items);
57
    }
58
59
    /**
60
     * @param $t
61
     * @return bool
62
     */
63
    public static function isClosure($t)
64
    {
65
        return is_object($t) && ($t instanceof \Closure);
66
    }
67
68
    /**
69
     * @return PluginManager
70
     */
71
    public static function pluginManager()
72
    {
73
        return App::make('ArtificerPluginManager');
74
    }
75
76
    /**
77
     * @return WidgetManager
78
     */
79
    public static function widgetManager()
80
    {
81
        return App::make('ArtificerWidgetManager');
82
    }
83
    /**
84
     * @param $plugin
85
     * @return mixed
86
     */
87
//    public static function getPlugin($plugin)
88
//    {
89
//        return with(App::make('ArtificerPluginManager'))->make($plugin);
90
//    }
91
92
    // Todo is it used anywhere?
93
//    public static function store($filepath = null, $content, $overide = false)
94
//    {
95
//        if (!$filepath) {
96
//            $pathinfo = pathinfo($filepath);
97
//            $filepath = $pathinfo['dirname'];
98
//        }
99
//
100
//        $path = explode('/', $filepath);
101
//        array_pop($path);
102
//        $path = join('/', $path);
103
//
104
//        if (!file_exists($path)) {
105
//            \File::makeDirectory($path, 0777, true, true);
106
//        }
107
//
108
//        if (!file_exists($filepath) || $overide) {
109
//            return \File::put($filepath, $content);
110
//        }
111
//
112
//        return false;
113
//    }
114
}