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); |
|
|
|
|
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
|
|
|
|
110
|
|
|
Route::get($name.'/{id}/revisions', [ |
111
|
|
|
'as' => 'crud.'.$name.'.listRevisions', |
112
|
|
|
'uses' => $controller.'@listRevisions', |
113
|
|
|
]); |
114
|
|
|
|
115
|
|
|
Route::post($name.'/{id}/revisions/{revisionId}/restore', [ |
116
|
|
|
'as' => 'crud.'.$name.'.restoreRevision', |
117
|
|
|
'uses' => $controller.'@restoreRevision', |
118
|
|
|
]); |
119
|
|
|
|
120
|
|
|
$options_with_default_route_names = array_merge([ |
121
|
|
|
'names' => [ |
122
|
|
|
'index' => 'crud.'.$name.'.index', |
123
|
|
|
'create' => 'crud.'.$name.'.create', |
124
|
|
|
'store' => 'crud.'.$name.'.store', |
125
|
|
|
'edit' => 'crud.'.$name.'.edit', |
126
|
|
|
'update' => 'crud.'.$name.'.update', |
127
|
|
|
'show' => 'crud.'.$name.'.show', |
128
|
|
|
'destroy' => 'crud.'.$name.'.destroy', |
129
|
|
|
], |
130
|
|
|
], $options); |
131
|
|
|
|
132
|
|
|
Route::resource($name, $controller, $options_with_default_route_names); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
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_CBC
could 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.