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
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Array of Flare assets and where they should be published to. |
24
|
|
|
* |
25
|
|
|
* @var array |
26
|
|
|
*/ |
27
|
|
|
protected $assets = [ |
28
|
|
|
'public/flare' => 'vendor/flare', |
29
|
|
|
'public/AdminLTE/dist' => 'vendor/flare', |
30
|
|
|
'public/AdminLTE/plugins' => 'vendor/flare/plugins', |
31
|
|
|
'public/AdminLTE/bootstrap' => 'vendor/flare/bootstrap', |
32
|
|
|
]; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Perform post-registration booting of services. |
36
|
|
|
* |
37
|
|
|
* @return void |
38
|
|
|
*/ |
39
|
|
|
public function boot() |
40
|
|
|
{ |
41
|
|
|
$this->publishAssets(); |
42
|
|
|
$this->publishConfig(); |
43
|
|
|
$this->publishMigrations(); |
44
|
|
|
$this->publishViews(); |
45
|
|
|
|
46
|
|
|
$this->app->bind( |
47
|
|
|
\LaravelFlare\Flare\Contracts\Permissions\Permissionable::class, |
48
|
|
|
\Config::get('flare.config.permissions') |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Register any package services. |
54
|
|
|
* |
55
|
|
|
* @return void |
56
|
|
|
*/ |
57
|
|
|
public function register() |
58
|
|
|
{ |
59
|
|
|
$this->registerServiceProviders(); |
60
|
|
|
$this->registerFlareFacade(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Register Service Providers |
65
|
|
|
* |
66
|
|
|
* @return void |
67
|
|
|
*/ |
68
|
|
|
protected function registerServiceProviders() |
69
|
|
|
{ |
70
|
|
|
foreach ($this->serviceProviders as $class) { |
71
|
|
|
$this->app->register($class); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Register the Flare Facade |
77
|
|
|
* |
78
|
|
|
* @return void |
79
|
|
|
*/ |
80
|
|
|
protected function registerFlareFacade() |
81
|
|
|
{ |
82
|
|
|
$this->app->singleton('flare', function ($app) { |
83
|
|
|
return $app->make(\LaravelFlare\Flare\Flare::class); |
84
|
|
|
}); |
85
|
|
|
|
86
|
|
|
AliasLoader::getInstance()->alias('Flare', \LaravelFlare\Flare\Facades\Flare::class); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Publishes the Flare Assets to the appropriate directories. |
91
|
|
|
* |
92
|
|
|
* @return void |
93
|
|
|
*/ |
94
|
|
|
protected function publishAssets() |
95
|
|
|
{ |
96
|
|
|
$assets = []; |
97
|
|
|
|
98
|
|
|
foreach ($this->assets as $location => $asset) { |
99
|
|
|
$assets[$this->basePath($location)] = base_path($asset); |
|
|
|
|
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
$this->publishes($assets, 'public'); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Publishes the Flare Config File |
107
|
|
|
* |
108
|
|
|
* @return void |
109
|
|
|
*/ |
110
|
|
|
protected function publishConfig() |
111
|
|
|
{ |
112
|
|
|
$this->publishes([ |
113
|
|
|
$this->basePath('config/flare/config.php') => config_path('flare/config.php'), |
|
|
|
|
114
|
|
|
]); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Publishes the Flare Database Migrations |
119
|
|
|
* |
120
|
|
|
* @return void |
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
|
|
|
* @return void |
134
|
|
|
*/ |
135
|
|
|
protected function publishViews() |
136
|
|
|
{ |
137
|
|
|
$this->loadViewsFrom($this->basePath('resources/views'), 'flare'); |
|
|
|
|
138
|
|
|
$this->publishes([ |
139
|
|
|
$this->basePath('resources/views') => base_path('resources/views/vendor/flare'), |
|
|
|
|
140
|
|
|
]); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Returns the path to a provided file within the Flare package. |
145
|
|
|
* |
146
|
|
|
* @param boolean $fiepath |
|
|
|
|
147
|
|
|
* |
148
|
|
|
* @return string |
149
|
|
|
*/ |
150
|
|
|
private function basePath($filepath = false) |
151
|
|
|
{ |
152
|
|
|
return __DIR__.'/../' . $filepath; |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: