Completed
Push — dev ( 9ff19d...9155f2 )
by Marc
03:27
created

Artificer::assetManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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) {
0 ignored issues
show
Unused Code introduced by
The parameter $styles is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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
}