1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LaravelFlare\Flare; |
4
|
|
|
|
5
|
|
|
use Illuminate\Foundation\AliasLoader; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
|
8
|
|
|
class FlareServiceProvider extends ServiceProvider |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Array of Flare Service Providers to be Registered. |
12
|
|
|
* |
13
|
|
|
* @var array |
14
|
|
|
*/ |
15
|
|
|
protected $serviceProviders = [ |
16
|
|
|
\LaravelFlare\Flare\Providers\AuthServiceProvider::class, |
17
|
|
|
\LaravelFlare\Flare\Providers\ArtisanServiceProvider::class, |
18
|
|
|
\LaravelFlare\Flare\Providers\EventServiceProvider::class, |
19
|
|
|
\LaravelFlare\Flare\Providers\RouteServiceProvider::class, |
20
|
|
|
|
21
|
|
|
// External Components |
22
|
|
|
\LaravelFlare\Fields\FieldServiceProvider::class, |
23
|
|
|
]; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Array of Flare assets and where they should be published to. |
27
|
|
|
* |
28
|
|
|
* @var array |
29
|
|
|
*/ |
30
|
|
|
protected $assets = [ |
31
|
|
|
'public/flare' => 'vendor/flare', |
32
|
|
|
'public/AdminLTE/dist' => 'vendor/flare', |
33
|
|
|
'public/AdminLTE/plugins' => 'vendor/flare/plugins', |
34
|
|
|
'public/AdminLTE/bootstrap' => 'vendor/flare/bootstrap', |
35
|
|
|
]; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Create a new service provider instance. |
39
|
|
|
* |
40
|
|
|
* @param \Illuminate\Contracts\Foundation\Application $app |
41
|
|
|
* @return void |
|
|
|
|
42
|
|
|
*/ |
43
|
|
|
public function __construct($app) |
44
|
|
|
{ |
45
|
|
|
parent::__construct($app); |
46
|
|
|
|
47
|
|
|
$this->app->singleton('flare', function ($app) { |
48
|
|
|
return $app->make(\LaravelFlare\Flare\Flare::class, [$app]); |
49
|
|
|
}); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Perform post-registration booting of services. |
54
|
|
|
*/ |
55
|
|
|
public function boot() |
56
|
|
|
{ |
57
|
|
|
$this->publishAssets(); |
58
|
|
|
$this->publishConfig(); |
59
|
|
|
$this->publishMigrations(); |
60
|
|
|
$this->publishViews(); |
61
|
|
|
|
62
|
|
|
$this->app->bind( |
63
|
|
|
\LaravelFlare\Flare\Contracts\Permissions\Permissionable::class, |
64
|
|
|
\Config::get('flare.config.permissions') |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Register any package services. |
70
|
|
|
*/ |
71
|
|
|
public function register() |
72
|
|
|
{ |
73
|
|
|
$this->registerFlareFacade(); |
74
|
|
|
$this->registerServiceProviders(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Register Service Providers. |
79
|
|
|
*/ |
80
|
|
|
protected function registerServiceProviders() |
81
|
|
|
{ |
82
|
|
|
foreach ($this->serviceProviders as $class) { |
83
|
|
|
$this->app->register($class); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Register the Flare Facade. |
89
|
|
|
*/ |
90
|
|
|
protected function registerFlareFacade() |
91
|
|
|
{ |
92
|
|
|
AliasLoader::getInstance()->alias('Flare', \LaravelFlare\Flare\Facades\Flare::class); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Publishes the Flare Assets to the appropriate directories. |
97
|
|
|
*/ |
98
|
|
|
protected function publishAssets() |
99
|
|
|
{ |
100
|
|
|
$assets = []; |
101
|
|
|
|
102
|
|
|
foreach ($this->assets as $location => $asset) { |
103
|
|
|
$assets[$this->basePath($location)] = base_path($asset); |
|
|
|
|
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
$this->publishes($assets, 'public'); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Publishes the Flare Config File. |
111
|
|
|
*/ |
112
|
|
|
protected function publishConfig() |
113
|
|
|
{ |
114
|
|
|
$this->publishes([ |
115
|
|
|
$this->basePath('config/flare/config.php') => config_path('flare/config.php'), |
|
|
|
|
116
|
|
|
]); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Publishes the Flare Database Migrations. |
121
|
|
|
*/ |
122
|
|
|
protected function publishMigrations() |
123
|
|
|
{ |
124
|
|
|
$this->publishes([ |
125
|
|
|
$this->basePath('Flare/Database/Migrations') => base_path('database/migrations'), |
|
|
|
|
126
|
|
|
]); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Publishes the Flare Views and defines the location |
131
|
|
|
* they should be looked for in the application. |
132
|
|
|
*/ |
133
|
|
|
protected function publishViews() |
134
|
|
|
{ |
135
|
|
|
$this->loadViewsFrom($this->basePath('resources/views'), 'flare'); |
|
|
|
|
136
|
|
|
$this->publishes([ |
137
|
|
|
$this->basePath('resources/views') => base_path('resources/views/vendor/flare'), |
|
|
|
|
138
|
|
|
]); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Returns the path to a provided file within the Flare package. |
143
|
|
|
* |
144
|
|
|
* @param bool $fiepath |
|
|
|
|
145
|
|
|
* |
146
|
|
|
* @return string |
147
|
|
|
*/ |
148
|
|
|
private function basePath($filepath = false) |
149
|
|
|
{ |
150
|
|
|
return __DIR__.'/../'.$filepath; |
151
|
|
|
} |
152
|
|
|
} |
153
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.