Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#136)
by Owen
02:46
created

CrudServiceProvider::resource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 50
Code Lines 36

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 36
nc 1
nop 3
dl 0
loc 50
rs 9.3333
c 0
b 0
f 0
1
<?php
2
3
namespace Backpack\CRUD;
4
5
use Illuminate\Support\ServiceProvider;
6
use Route;
7
8
class CrudServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Indicates if loading of the provider is deferred.
12
     *
13
     * @var bool
14
     */
15
    protected $defer = false;
16
17
    /**
18
     * Perform post-registration booting of services.
19
     *
20
     * @return void
21
     */
22
    public function boot()
23
    {
24
        // LOAD THE VIEWS
25
26
        // - first the published/overwritten views (in case they have any changes)
27
        $this->loadViewsFrom(resource_path('views/vendor/backpack/crud'), 'crud');
28
        // - then the stock views that come with the package, in case a published view might be missing
29
        $this->loadViewsFrom(realpath(__DIR__.'/resources/views'), 'crud');
30
31
        $this->loadTranslationsFrom(realpath(__DIR__.'/resources/lang'), 'backpack');
32
33
34
        // PUBLISH FILES
35
36
        // publish lang files
37
        $this->publishes([__DIR__.'/resources/lang' => resource_path('lang/vendor/backpack')], 'lang');
38
39
        // publish views
40
        $this->publishes([__DIR__.'/resources/views' => resource_path('views/vendor/backpack/crud')], 'views');
41
42
        // publish config file
43
        $this->publishes([__DIR__.'/config/backpack/crud.php' => resource_path('config/backpack/crud.php')], 'config');
44
45
        // publish public Backpack CRUD assets
46
        $this->publishes([__DIR__.'/public' => public_path('vendor/backpack')], 'public');
47
48
        // publish custom files for elFinder
49
        $this->publishes([
50
                            __DIR__.'/config/elfinder.php'      => config_path('elfinder.php'),
51
                            __DIR__.'/resources/views-elfinder' => resource_path('views/vendor/elfinder'),
52
                            ], 'elfinder');
53
54
55
        // use the vendor configuration file as fallback
56
        $this->mergeConfigFrom(
57
            __DIR__.'/config/backpack/crud.php', 'backpack.crud'
58
        );
59
    }
60
61
    /**
62
     * Register any package services.
63
     *
64
     * @return void
65
     */
66
    public function register()
67
    {
68
        $this->app->bind('CRUD', function ($app) {
69
            return new CRUD($app);
70
        });
71
72
        // register its dependencies
73
        $this->app->register(\Backpack\Base\BaseServiceProvider::class);
74
        $this->app->register(\Collective\Html\HtmlServiceProvider::class);
75
        $this->app->register(\Barryvdh\Elfinder\ElfinderServiceProvider::class);
76
        $this->app->register(\Intervention\Image\ImageServiceProvider::class);
77
78
        // register their aliases
79
        $loader = \Illuminate\Foundation\AliasLoader::getInstance();
80
        $loader->alias('CRUD', \Backpack\CRUD\CrudServiceProvider::class);
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
81
        $loader->alias('Form', \Collective\Html\FormFacade::class);
82
        $loader->alias('Html', \Collective\Html\HtmlFacade::class);
83
        $loader->alias('Image', \Intervention\Image\Facades\Image::class);
84
    }
85
86
    public static function resource($name, $controller, array $options = [])
87
    {
88
        // CRUD routes
89
        Route::post($name.'/search', [
90
            'as' => 'crud.'.$name.'.search',
91
            'uses' => $controller.'@search',
92
        ]);
93
        Route::get($name.'/reorder', [
94
            'as' => 'crud.'.$name.'.reorder',
95
            'uses' => $controller.'@reorder',
96
        ]);
97
        Route::post($name.'/reorder', [
98
            'as' => 'crud.'.$name.'.save.reorder',
99
            'uses' => $controller.'@saveReorder',
100
        ]);
101
        Route::get($name.'/{id}/details', [
102
            'as' => 'crud.'.$name.'.showDetailsRow',
103
            'uses' => $controller.'@showDetailsRow',
104
        ]);
105
        Route::get($name.'/{id}/translate/{lang}', [
106
            'as' => 'crud.'.$name.'.translateItem',
107
            'uses' => $controller.'@translateItem',
108
        ]);
109
        Route::get($name.'/{id}/revisions', [
110
            'as' => 'crud.'.$name.'.listRevisions',
111
            'uses' => $controller.'@listRevisions',
112
        ]);
113
        Route::post($name.'/{id}/revisions/{revisionId}/restore', [
114
            'as' => 'crud.'.$name.'.restoreRevision',
115
            'uses' => $controller.'@restoreRevision',
116
        ]);
117
        Route::any($name.'/unicity', [
118
            'as' => 'crud.'.$name.'.unicity',
119
            'uses' => $controller.'@unicity',
120
        ]);
121
122
        $options_with_default_route_names = array_merge([
123
            'names' => [
124
                'index'     => 'crud.'.$name.'.index',
125
                'create'    => 'crud.'.$name.'.create',
126
                'store'     => 'crud.'.$name.'.store',
127
                'edit'      => 'crud.'.$name.'.edit',
128
                'update'    => 'crud.'.$name.'.update',
129
                'show'      => 'crud.'.$name.'.show',
130
                'destroy'   => 'crud.'.$name.'.destroy',
131
                ],
132
            ], $options);
133
134
        Route::resource($name, $controller, $options_with_default_route_names);
135
    }
136
}
137