| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Backpack\CRUD; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Illuminate\Support\ServiceProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Route; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 9 |  |  | class CrudServiceProvider extends ServiceProvider | 
            
                                                                        
                            
            
                                    
            
            
                | 10 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 11 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 12 |  |  |      * Indicates if loading of the provider is deferred. | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  |      * @var bool | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |     protected $defer = false; | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |      * Perform post-registration booting of services. | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |      * @return void | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     public function boot() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         // LOAD THE VIEWS | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         // - first the published/overwritten views (in case they have any changes) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         $this->loadViewsFrom(resource_path('views/vendor/backpack/crud'), 'crud'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         // - then the stock views that come with the package, in case a published view might be missing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $this->loadViewsFrom(realpath(__DIR__.'/resources/views'), 'crud'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $this->loadTranslationsFrom(realpath(__DIR__.'/resources/lang'), 'backpack'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         // PUBLISH FILES | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         // publish lang files | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $this->publishes([__DIR__.'/resources/lang' => resource_path('lang/vendor/backpack')], 'lang'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         // publish views | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $this->publishes([__DIR__.'/resources/views' => resource_path('views/vendor/backpack/crud')], 'views'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         // publish config file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $this->publishes([__DIR__.'/config/backpack/crud.php' => resource_path('config/backpack/crud.php')], 'config'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         // publish public Backpack CRUD assets | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         $this->publishes([__DIR__.'/public' => public_path('vendor/backpack')], 'public'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         // publish custom files for elFinder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         $this->publishes([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |                             __DIR__.'/config/elfinder.php'      => config_path('elfinder.php'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |                             __DIR__.'/resources/views-elfinder' => resource_path('views/vendor/elfinder'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |                             ], 'elfinder'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         // use the vendor configuration file as fallback | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $this->mergeConfigFrom( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             __DIR__.'/config/backpack/crud.php', 'backpack.crud' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 60 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |      * Register any package services. | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |      * @return void | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     public function register() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $this->app->bind('CRUD', function ($app) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             return new CRUD($app); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         // register its dependencies | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         $this->app->register(\Backpack\Base\BaseServiceProvider::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         $this->app->register(\Collective\Html\HtmlServiceProvider::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         $this->app->register(\Barryvdh\Elfinder\ElfinderServiceProvider::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         $this->app->register(\Intervention\Image\ImageServiceProvider::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         // register their aliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         $loader = \Illuminate\Foundation\AliasLoader::getInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         $loader->alias('CRUD', \Backpack\CRUD\CrudServiceProvider::class); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $loader->alias('Form', \Collective\Html\FormFacade::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         $loader->alias('Html', \Collective\Html\HtmlFacade::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         $loader->alias('Image', \Intervention\Image\Facades\Image::class); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 85 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     public static function resource($name, $controller, array $options = []) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         // CRUD routes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         Route::post($name.'/search', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |             'as' => 'crud.'.$name.'.search', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |             'uses' => $controller.'@search', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         Route::get($name.'/reorder', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |             'as' => 'crud.'.$name.'.reorder', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |             'uses' => $controller.'@reorder', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         Route::post($name.'/reorder', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |             'as' => 'crud.'.$name.'.save.reorder', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |             'uses' => $controller.'@saveReorder', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         Route::get($name.'/{id}/details', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |             'as' => 'crud.'.$name.'.showDetailsRow', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |             'uses' => $controller.'@showDetailsRow', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         Route::get($name.'/{id}/translate/{lang}', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             'as' => 'crud.'.$name.'.translateItem', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |             'uses' => $controller.'@translateItem', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         Route::get($name.'/{id}/revisions', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |             'as' => 'crud.'.$name.'.listRevisions', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             'uses' => $controller.'@listRevisions', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         Route::post($name.'/{id}/revisions/{revisionId}/restore', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |             'as' => 'crud.'.$name.'.restoreRevision', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |             'uses' => $controller.'@restoreRevision', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         $options_with_default_route_names = array_merge([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |             'names' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |                 'index'     => 'crud.'.$name.'.index', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |                 'create'    => 'crud.'.$name.'.create', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |                 'store'     => 'crud.'.$name.'.store', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |                 'edit'      => 'crud.'.$name.'.edit', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |                 'update'    => 'crud.'.$name.'.update', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |                 'show'      => 'crud.'.$name.'.show', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |                 'destroy'   => 'crud.'.$name.'.destroy', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |                 ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |             ], $options); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         Route::resource($name, $controller, $options_with_default_route_names); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         return new CrudInjectable($name, $controller, $options); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 134 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 135 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 136 |  |  |  | 
            
                        
This check looks for accesses to local static members using the fully qualified name instead of
self::.While this is perfectly valid, the fully qualified name of
Certificate::TRIPLEDES_CBCcould just as well be replaced byself::TRIPLEDES_CBC. Referencing local members withself::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.