|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Backpack\CRUD; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
|
6
|
|
|
|
|
7
|
|
|
class CrudServiceProvider extends ServiceProvider |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Indicates if loading of the provider is deferred. |
|
11
|
|
|
* |
|
12
|
|
|
* @var bool |
|
13
|
|
|
*/ |
|
14
|
|
|
protected $defer = false; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Perform post-registration booting of services. |
|
18
|
|
|
* |
|
19
|
|
|
* @return void |
|
20
|
|
|
*/ |
|
21
|
|
|
public function boot() |
|
22
|
|
|
{ |
|
23
|
|
|
// LOAD THE VIEWS |
|
24
|
|
|
|
|
25
|
|
|
// - first the published/overwritten views (in case they have any changes) |
|
26
|
|
|
$this->loadViewsFrom(resource_path('views/vendor/backpack/crud'), 'crud'); |
|
27
|
|
|
// - then the stock views that come with the package, in case a published view might be missing |
|
28
|
|
|
$this->loadViewsFrom(realpath(__DIR__.'/resources/views'), 'crud'); |
|
29
|
|
|
|
|
30
|
|
|
$this->loadTranslationsFrom(realpath(__DIR__.'/resources/lang'), 'backpack'); |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
// PUBLISH FILES |
|
34
|
|
|
|
|
35
|
|
|
// publish lang files |
|
36
|
|
|
$this->publishes([__DIR__.'/resources/lang' => resource_path('lang/vendor/backpack')], 'lang'); |
|
37
|
|
|
|
|
38
|
|
|
// publish views |
|
39
|
|
|
$this->publishes([__DIR__.'/resources/views' => resource_path('views/vendor/backpack/crud')], 'views'); |
|
40
|
|
|
|
|
41
|
|
|
// publish config file |
|
42
|
|
|
$this->publishes([__DIR__.'/config' => config_path()], 'config'); |
|
43
|
|
|
|
|
44
|
|
|
// publish public Backpack CRUD assets |
|
45
|
|
|
$this->publishes([__DIR__.'/public' => public_path('vendor/backpack')], 'public'); |
|
46
|
|
|
|
|
47
|
|
|
// publish custom files for elFinder |
|
48
|
|
|
$this->publishes([ |
|
49
|
|
|
__DIR__.'/config/elfinder.php' => config_path('elfinder.php'), |
|
50
|
|
|
__DIR__.'/resources/views-elfinder' => resource_path('views/vendor/elfinder'), |
|
51
|
|
|
], 'elfinder'); |
|
52
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
// use the vendor configuration file as fallback |
|
55
|
|
|
$this->mergeConfigFrom( |
|
56
|
|
|
__DIR__.'/config/backpack/crud.php', 'backpack.crud' |
|
57
|
|
|
); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Register any package services. |
|
62
|
|
|
* |
|
63
|
|
|
* @return void |
|
64
|
|
|
*/ |
|
65
|
|
|
public function register() |
|
66
|
|
|
{ |
|
67
|
|
|
$this->app->bind('CRUD', function ($app) { |
|
68
|
|
|
return new CRUD($app); |
|
69
|
|
|
}); |
|
70
|
|
|
|
|
71
|
|
|
// register its dependencies |
|
72
|
|
|
$this->app->register(\Backpack\Base\BaseServiceProvider::class); |
|
73
|
|
|
$this->app->register(\Collective\Html\HtmlServiceProvider::class); |
|
74
|
|
|
$this->app->register(\Barryvdh\Elfinder\ElfinderServiceProvider::class); |
|
75
|
|
|
$this->app->register(\Intervention\Image\ImageServiceProvider::class); |
|
76
|
|
|
|
|
77
|
|
|
// register their aliases |
|
78
|
|
|
$loader = \Illuminate\Foundation\AliasLoader::getInstance(); |
|
79
|
|
|
$loader->alias('CRUD', \Backpack\CRUD\CrudServiceProvider::class); |
|
|
|
|
|
|
80
|
|
|
$loader->alias('Form', \Collective\Html\FormFacade::class); |
|
81
|
|
|
$loader->alias('Html', \Collective\Html\HtmlFacade::class); |
|
82
|
|
|
$loader->alias('Image', \Intervention\Image\Facades\Image::class); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public static function resource($name, $controller, array $options = []) |
|
86
|
|
|
{ |
|
87
|
|
|
return new CrudRouter($name, $controller, $options); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
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.