Completed
Push — dev ( 917cb5...992eab )
by Marc
10:46
created

Artificer::getCurrentAction()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

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