1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jumilla\Addomnipot\Laravel; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider as BaseServiceProvider; |
6
|
|
|
|
7
|
|
|
class ServiceProvider extends BaseServiceProvider |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Addon environment. |
11
|
|
|
* |
12
|
|
|
* @var \Jumilla\Addomnipot\Laravel\Environment |
13
|
|
|
*/ |
14
|
|
|
protected $addonEnvironment; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Register the service provider. |
18
|
|
|
*/ |
19
|
1 |
|
public function register() |
20
|
|
|
{ |
21
|
1 |
|
$this->app->instance('addon', $this->addonEnvironment = new AddonEnvironment($app)); |
|
|
|
|
22
|
|
|
$this->app->alias('addon', AddonEnvironment::class); |
23
|
|
|
|
24
|
|
|
$this->app->singleton(Generator::class, function ($app) { |
|
|
|
|
25
|
|
|
return new Generator(); |
26
|
|
|
}); |
27
|
|
|
|
28
|
|
|
$this->registerCommands(); |
29
|
|
|
|
30
|
|
|
$this->registerClassResolvers(); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Register the cache related console commands. |
35
|
|
|
*/ |
36
|
|
|
public function registerCommands() |
37
|
|
|
{ |
38
|
|
|
$this->app->singleton('command.addon.check', function ($app) { |
|
|
|
|
39
|
|
|
return new Console\AddonCheckCommand(); |
40
|
|
|
}); |
41
|
|
|
|
42
|
|
|
$this->app->singleton('command.addon.make', function ($app) { |
|
|
|
|
43
|
|
|
return new Console\AddonMakeCommand(); |
44
|
|
|
}); |
45
|
|
|
|
46
|
|
|
$this->app->singleton('command.addon.name', function ($app) { |
|
|
|
|
47
|
|
|
return new Console\AddonNameCommand(); |
48
|
|
|
}); |
49
|
|
|
|
50
|
|
|
$this->app->singleton('command.addon.remove', function ($app) { |
|
|
|
|
51
|
|
|
return new Console\AddonRemoveCommand(); |
52
|
|
|
}); |
53
|
|
|
|
54
|
|
|
$this->app->singleton('command.addon.status', function ($app) { |
|
|
|
|
55
|
|
|
return new Console\AddonStatusCommand(); |
56
|
|
|
}); |
57
|
|
|
|
58
|
|
|
$this->commands([ |
59
|
|
|
'command.addon.check', |
60
|
|
|
'command.addon.make', |
61
|
|
|
'command.addon.name', |
62
|
|
|
'command.addon.remove', |
63
|
|
|
'command.addon.status', |
64
|
|
|
]); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
*/ |
69
|
|
|
protected function registerClassResolvers() |
70
|
|
|
{ |
71
|
|
|
AddonClassLoader::register($this->addonEnvironment, $this->addonEnvironment->addons()); |
72
|
|
|
|
73
|
|
|
AliasResolver::register($this->app['path'], $addons, $this->app['config']->get('app.aliases')); |
|
|
|
|
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.