1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jumilla\Addomnipot\Laravel; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider as BaseServiceProvider; |
6
|
|
|
use Illuminate\Contracts\Http\Kernel as HttpKernel; |
7
|
|
|
|
8
|
|
|
class ServiceProvider extends BaseServiceProvider |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Addon environment. |
12
|
|
|
* |
13
|
|
|
* @var \Jumilla\Addomnipot\Laravel\Environment |
14
|
|
|
*/ |
15
|
|
|
protected $environment; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Register the service provider. |
19
|
|
|
*/ |
20
|
2 |
|
public function register() |
21
|
|
|
{ |
22
|
2 |
|
$app = $this->app; |
23
|
|
|
|
24
|
2 |
|
$app->instance('addon', $this->environment = new Environment($app)); |
25
|
2 |
|
$app->alias('addon', Environment::class); |
26
|
|
|
|
27
|
|
|
$app->singleton(Generator::class, function ($app) { |
|
|
|
|
28
|
|
|
return new Generator(); |
29
|
2 |
|
}); |
30
|
|
|
|
31
|
2 |
|
$this->registerCommands(); |
32
|
|
|
|
33
|
2 |
|
$app['events']->fire(new Events\AddonWorldCreated($this->environment)); |
34
|
|
|
|
35
|
2 |
|
$this->registerClassResolvers(); |
36
|
|
|
|
37
|
2 |
|
(new Registrar)->register($app, $this->environment->addons()); |
38
|
|
|
|
39
|
2 |
|
$app['events']->fire(new Events\AddonRegistered($this->environment)); |
40
|
2 |
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Register the cache related console commands. |
44
|
|
|
*/ |
45
|
2 |
|
public function registerCommands() |
46
|
|
|
{ |
47
|
|
|
$this->app->singleton('command.addon.list', function ($app) { |
|
|
|
|
48
|
1 |
|
return new Commands\AddonListCommand(); |
49
|
2 |
|
}); |
50
|
|
|
|
51
|
|
|
$this->app->singleton('command.addon.status', function ($app) { |
|
|
|
|
52
|
1 |
|
return new Commands\AddonStatusCommand(); |
53
|
2 |
|
}); |
54
|
|
|
|
55
|
|
|
$this->app->singleton('command.addon.make', function ($app) { |
|
|
|
|
56
|
1 |
|
return new Commands\AddonMakeCommand(); |
57
|
2 |
|
}); |
58
|
|
|
|
59
|
|
|
$this->app->singleton('command.addon.name', function ($app) { |
|
|
|
|
60
|
1 |
|
return new Commands\AddonNameCommand(); |
61
|
2 |
|
}); |
62
|
|
|
|
63
|
2 |
|
$this->app->singleton('command.addon.remove', function ($app) { |
|
|
|
|
64
|
1 |
|
return new Commands\AddonRemoveCommand(); |
65
|
2 |
|
}); |
66
|
|
|
|
67
|
2 |
|
$this->commands([ |
68
|
2 |
|
'command.addon.list', |
69
|
|
|
'command.addon.status', |
70
|
|
|
'command.addon.make', |
71
|
|
|
'command.addon.name', |
72
|
|
|
'command.addon.remove', |
73
|
|
|
]); |
74
|
2 |
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
*/ |
78
|
2 |
|
protected function registerClassResolvers() |
79
|
|
|
{ |
80
|
2 |
|
$addons = $this->environment->addons(); |
81
|
|
|
|
82
|
2 |
|
ClassLoader::register($this->environment, $addons); |
83
|
|
|
|
84
|
2 |
|
AliasResolver::register($this->app['path'], $addons, $this->app['config']->get('app.aliases', [])); |
85
|
2 |
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Boot the service provider. |
89
|
|
|
*/ |
90
|
1 |
|
public function boot() |
91
|
|
|
{ |
92
|
1 |
|
$app = $this->app; |
93
|
|
|
|
94
|
1 |
|
(new Registrar)->boot($app, $this->environment->addons()); |
95
|
|
|
|
96
|
1 |
|
$app['events']->fire(new Events\AddonBooted($this->environment)); |
97
|
1 |
|
} |
98
|
|
|
} |
99
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.