1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace guastallaigor\PhpBattlerite\ServiceProviders; |
4
|
|
|
|
5
|
|
|
use guastallaigor\PhpBattlerite\Facades\PhpBattlerite; |
6
|
|
|
use guastallaigor\PhpBattlerite\Main; |
7
|
|
|
use Illuminate\Support\ServiceProvider; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* PHP-Battlerite easy API. |
11
|
|
|
* |
12
|
|
|
* @category Games |
13
|
|
|
* |
14
|
|
|
* @author Igor Guastalla de Lima <[email protected]> |
15
|
|
|
* @copyright 2018 PHP Battlerite |
16
|
|
|
* @license MIT https://github.com/guastallaigor/php-battlerite/blob/master/LICENSE |
17
|
|
|
* |
18
|
|
|
* @link https://github.com/guastallaigor/php-battlerite |
19
|
|
|
*/ |
20
|
|
|
class PhpBattleriteServiceProvider extends ServiceProvider |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Indicates if loading of the provider is deferred. |
24
|
|
|
* |
25
|
|
|
* @var bool |
26
|
|
|
*/ |
27
|
|
|
protected $defer = false; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Publish the Config file from the Package to the App directory. |
31
|
|
|
* |
32
|
|
|
* @return void |
33
|
|
|
*/ |
34
|
|
|
public function boot() |
35
|
|
|
{ |
36
|
|
|
$this->configPublisher(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Register the service provider. |
41
|
|
|
* |
42
|
|
|
* @return void |
43
|
|
|
*/ |
44
|
|
|
public function register() |
45
|
|
|
{ |
46
|
|
|
/* |
47
|
|
|
* Implementation Bindings. |
48
|
|
|
*/ |
49
|
|
|
$this->implementationBindings(); |
50
|
|
|
|
51
|
|
|
/* |
52
|
|
|
* Facade Bindings. |
53
|
|
|
*/ |
54
|
|
|
$this->facadeBindings(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Binding app to Main class. |
59
|
|
|
* |
60
|
|
|
* @return void |
61
|
|
|
*/ |
62
|
|
|
private function implementationBindings() |
63
|
|
|
{ |
64
|
|
|
$this->app->bind( |
65
|
|
|
Main::class |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Publish the Config file from the Package to the App directory. |
71
|
|
|
* |
72
|
|
|
* @return void |
73
|
|
|
*/ |
74
|
|
|
private function configPublisher() |
75
|
|
|
{ |
76
|
|
|
// When users execute Laravel's vendor:publish command, the config file will be copied to the specified location |
77
|
|
|
$this->publishes( |
78
|
|
|
[ |
79
|
|
|
__DIR__.'/Config/phpbattlerite.php' => config_path('phpbattlerite.php'), |
80
|
|
|
] |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Binding app to the Facede. |
86
|
|
|
* |
87
|
|
|
* @return void |
88
|
|
|
*/ |
89
|
|
|
private function facadeBindings() |
90
|
|
|
{ |
91
|
|
|
// Register 'PhpBattlerite' Alias, |
92
|
|
|
// So users don't have to add the Alias to the 'app/config/app.php' |
93
|
|
|
$this->app->booting( |
94
|
|
|
function () { |
95
|
|
|
$loader = \Illuminate\Foundation\AliasLoader::getInstance(); |
96
|
|
|
$loader->alias('PhpBattlerite', PhpBattleriteFacede::class); |
97
|
|
|
} |
98
|
|
|
); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Get the services provided by the provider. |
103
|
|
|
* |
104
|
|
|
* @return array |
105
|
|
|
*/ |
106
|
|
|
public function provides() |
107
|
|
|
{ |
108
|
|
|
return []; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|