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\CompatibilityServiceProvider::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' => 'public/vendor/flare', |
32
|
|
|
'public/AdminLTE/dist' => 'public/vendor/flare', |
33
|
|
|
'public/AdminLTE/plugins' => 'public/vendor/flare/plugins', |
34
|
|
|
'public/AdminLTE/bootstrap' => 'public/vendor/flare/bootstrap', |
35
|
|
|
]; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Create a new service provider instance. |
39
|
|
|
* |
40
|
|
|
* @param \Illuminate\Contracts\Foundation\Application $app |
41
|
|
|
*/ |
42
|
|
|
public function __construct($app) |
43
|
|
|
{ |
44
|
|
|
parent::__construct($app); |
45
|
|
|
|
46
|
|
|
$this->app->singleton('flare', function ($app) { |
47
|
|
|
return $app->make(\LaravelFlare\Flare\Flare::class, [$app]); |
48
|
|
|
}); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Perform post-registration booting of services. |
53
|
|
|
*/ |
54
|
|
|
public function boot() |
55
|
|
|
{ |
56
|
|
|
$this->publishAssets(); |
57
|
|
|
$this->publishConfig(); |
58
|
|
|
$this->publishMigrations(); |
59
|
|
|
$this->publishViews(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Register any package services. |
64
|
|
|
*/ |
65
|
|
|
public function register() |
66
|
|
|
{ |
67
|
|
|
$this->registerFlareFacade(); |
68
|
|
|
$this->registerServiceProviders(); |
69
|
|
|
$this->registerBindings(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Register the Flare Facade. |
74
|
|
|
*/ |
75
|
|
|
protected function registerFlareFacade() |
76
|
|
|
{ |
77
|
|
|
AliasLoader::getInstance()->alias('Flare', \LaravelFlare\Flare\Facades\Flare::class); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Register Service Providers. |
82
|
|
|
*/ |
83
|
|
|
protected function registerServiceProviders() |
84
|
|
|
{ |
85
|
|
|
foreach ($this->serviceProviders as $class) { |
86
|
|
|
$this->app->register($class); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Register the Flare Bindings. |
92
|
|
|
*/ |
93
|
|
|
protected function registerBindings() |
94
|
|
|
{ |
95
|
|
|
$this->app->bind( |
96
|
|
|
\LaravelFlare\Flare\Contracts\Permissions\Permissionable::class, |
97
|
|
|
\Flare::config('permissions') |
98
|
|
|
); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Publishes the Flare Assets to the appropriate directories. |
103
|
|
|
*/ |
104
|
|
|
protected function publishAssets() |
105
|
|
|
{ |
106
|
|
|
$assets = []; |
107
|
|
|
|
108
|
|
|
foreach ($this->assets as $location => $asset) { |
109
|
|
|
$assets[$this->basePath($location)] = base_path($asset); |
|
|
|
|
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
$this->publishes($assets); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Publishes the Flare Config File. |
117
|
|
|
*/ |
118
|
|
|
protected function publishConfig() |
119
|
|
|
{ |
120
|
|
|
$this->publishes([ |
121
|
|
|
$this->basePath('config/flare/config.php') => config_path('flare/config.php'), |
|
|
|
|
122
|
|
|
]); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Publishes the Flare Database Migrations. |
127
|
|
|
*/ |
128
|
|
|
protected function publishMigrations() |
129
|
|
|
{ |
130
|
|
|
$this->publishes([ |
131
|
|
|
$this->basePath('Flare/Database/Migrations') => base_path('database/migrations'), |
|
|
|
|
132
|
|
|
]); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Publishes the Flare Views and defines the location |
137
|
|
|
* they should be looked for in the application. |
138
|
|
|
*/ |
139
|
|
|
protected function publishViews() |
140
|
|
|
{ |
141
|
|
|
$this->loadViewsFrom($this->basePath('resources/views'), 'flare'); |
|
|
|
|
142
|
|
|
$this->publishes([ |
143
|
|
|
$this->basePath('resources/views') => base_path('resources/views/vendor/flare'), |
|
|
|
|
144
|
|
|
]); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Returns the path to a provided file within the Flare package. |
149
|
|
|
* |
150
|
|
|
* @param bool $fiepath |
|
|
|
|
151
|
|
|
* |
152
|
|
|
* @return string |
153
|
|
|
*/ |
154
|
|
|
private function basePath($filepath = false) |
155
|
|
|
{ |
156
|
|
|
return __DIR__.'/../'.$filepath; |
157
|
|
|
} |
158
|
|
|
} |
159
|
|
|
|
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: