Completed
Push — dev ( 110236...0d804d )
by Marc
02:57
created

Artificer::isCoreExtension()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 1
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
    /**
65
     * @return \Stolz\Assets\Manager
66
     */
67
    public static function assetManager()
68
    {
69
        return App::make('ArtificerAssetManager');
70
    }
71
72
    public static function getCurrentModelId($items)
73
    {
74
        return BaseModelController::getCurrentModelId($items);
75
    }
76
77
    
78
    public static function addMenu($options)
79
    {
80
        return config(['admin.menu' => array_merge(self::getMenu(), $options)]);
81
    }
82
83
    protected static function getMenu()
84
    {
85
        return config('admin.menu');
86
    }
87
88
    // Todo is it used anywhere?
89
//    public static function store($filepath = null, $content, $overide = false)
90
//    {
91
//        if (!$filepath) {
92
//            $pathinfo = pathinfo($filepath);
93
//            $filepath = $pathinfo['dirname'];
94
//        }
95
//
96
//        $path = explode('/', $filepath);
97
//        array_pop($path);
98
//        $path = join('/', $path);
99
//
100
//        if (!file_exists($path)) {
101
//            \File::makeDirectory($path, 0777, true, true);
102
//        }
103
//
104
//        if (!file_exists($filepath) || $overide) {
105
//            return \File::put($filepath, $content);
106
//        }
107
//
108
//        return false;
109
//    }
110
}