1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LaravelZero\Framework\Bootstrappers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use LaravelZero\Framework\Providers; |
7
|
|
|
use Illuminate\Cache\CacheServiceProvider; |
8
|
|
|
use Illuminate\Events\EventServiceProvider; |
9
|
|
|
use LaravelZero\Framework\Commands\Component; |
10
|
|
|
use NunoMaduro\LaravelDesktopNotifier\LaravelDesktopNotifierServiceProvider; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* This is the Laravel Zero Framework Bootstrapper ServiceProviders class. |
14
|
|
|
* |
15
|
|
|
* @author Nuno Maduro <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
class ServiceProviders extends Bootstrapper |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* The application's core providers. |
21
|
|
|
* |
22
|
|
|
* @var string[] |
23
|
|
|
*/ |
24
|
|
|
protected $providers = [ |
25
|
|
|
Providers\ErrorHandler\ServiceProvider::class, |
26
|
|
|
EventServiceProvider::class, |
27
|
|
|
CacheServiceProvider::class, |
28
|
|
|
Providers\Composer\ServiceProvider::class, |
29
|
|
|
Providers\Scheduler\ServiceProvider::class, |
30
|
|
|
LaravelDesktopNotifierServiceProvider::class, |
31
|
|
|
]; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The application's core components. |
35
|
|
|
* |
36
|
|
|
* @var string[] |
37
|
|
|
*/ |
38
|
|
|
protected $components = [ |
39
|
|
|
Component\Illuminate\Database\ComponentProvider::class, |
40
|
|
|
Component\Illuminate\Filesystem\ComponentProvider::class, |
41
|
|
|
]; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* The application core aliases. |
45
|
|
|
* |
46
|
|
|
* @var array |
47
|
|
|
*/ |
48
|
|
|
protected $aliases = [ |
49
|
|
|
'app' => [\Illuminate\Contracts\Container\Container::class], |
50
|
|
|
'events' => [\Illuminate\Events\Dispatcher::class, \Illuminate\Contracts\Events\Dispatcher::class], |
51
|
|
|
'config' => [\Illuminate\Config\Repository::class, \Illuminate\Contracts\Config\Repository::class], |
52
|
|
|
'cache' => [\Illuminate\Cache\CacheManager::class, \Illuminate\Contracts\Cache\Factory::class], |
53
|
|
|
'cache.store' => [\Illuminate\Cache\Repository::class, \Illuminate\Contracts\Cache\Repository::class], |
54
|
|
|
]; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritdoc} |
58
|
|
|
*/ |
59
|
|
|
public function bootstrap(): void |
60
|
|
|
{ |
61
|
|
|
collect($this->providers) |
62
|
|
|
->merge($this->components) |
63
|
|
|
->merge( |
64
|
|
|
$this->container->make('config') |
65
|
|
|
->get('app.providers') |
66
|
|
|
) |
67
|
|
|
->each( |
68
|
|
|
function ($serviceProviderClass) { |
69
|
|
|
$this->call($serviceProviderClass, 'register'); |
70
|
|
|
} |
71
|
|
|
) |
72
|
|
|
->each( |
73
|
|
|
function ($serviceProviderClass) { |
74
|
|
|
$this->call($serviceProviderClass, 'boot'); |
75
|
|
|
} |
76
|
|
|
); |
77
|
|
|
|
78
|
|
|
foreach ($this->aliases as $key => $aliases) { |
79
|
|
|
foreach ($aliases as $alias) { |
80
|
|
|
$this->container->alias($key, $alias); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Creates a new instance of the service provider an |
87
|
|
|
* calls the provided method. |
88
|
|
|
* |
89
|
|
|
* @param string $serviceProviderClass |
90
|
|
|
* @param string $method |
91
|
|
|
*/ |
92
|
|
|
private function call(string $serviceProviderClass, string $method): void |
93
|
|
|
{ |
94
|
|
|
$provider = new $serviceProviderClass($this->container); |
95
|
|
|
if (method_exists($provider, $method)) { |
96
|
|
|
$this->container->call([$provider, $method]); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|