-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAggregateServiceProvider.php
More file actions
106 lines (90 loc) · 2.15 KB
/
AggregateServiceProvider.php
File metadata and controls
106 lines (90 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
namespace Apolune\Core;
use Illuminate\Support\AggregateServiceProvider as ServiceProvider;
abstract class AggregateServiceProvider extends ServiceProvider
{
/**
* Holds the Exceptions Handler implementation.
*
* @var App\Exceptions\Handler
*/
protected $exceptions;
/**
* The application's route middleware.
*
* @var array
*/
protected $middleware = [];
/**
* The provider class names.
*
* @var array
*/
protected $providers = [];
/**
* The binding class names & alias.
*
* @var array
*/
protected $bindings = [];
/**
* Create a new service provider instance.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public function __construct($app)
{
$this->app = $app;
$this->exceptions = $app['App\Exceptions\Handler'];
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->instances = [];
$this->registerMiddleware();
$this->registerProviders();
$this->registerBindings();
}
/**
* Register middleware.
*
* @return void
*/
protected function registerMiddleware()
{
if (! isset($this->middleware)) return;
foreach ($this->middleware as $key => $middleware) {
$this->app['router']->middleware($key, $middleware);
}
}
/**
* Register providers.
*
* @return void
*/
protected function registerProviders()
{
if (! isset($this->providers)) return;
foreach ($this->providers as $provider) {
$this->instances[] = $this->app->register($provider);
}
}
/**
* Register bindings.
*
* @return void
*/
protected function registerBindings()
{
if (! isset($this->bindings)) return;
foreach ($this->bindings as $alias => $binding) {
list($abstract, $concrete) = [key($binding), current($binding)];
$this->app->bind([$alias => $abstract], $concrete);
}
}
}