|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Multicoin\Api; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Route; |
|
6
|
|
|
use Illuminate\Support\ServiceProvider; |
|
7
|
|
|
|
|
8
|
|
|
class MulticoinServiceProvider extends ServiceProvider |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* Bootstrap the application services. |
|
12
|
|
|
*/ |
|
13
|
|
|
public function boot() |
|
14
|
|
|
{ |
|
15
|
|
|
$this->registerPublishing(); |
|
16
|
|
|
$this->registerRoutes(); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Register the application services. |
|
21
|
|
|
*/ |
|
22
|
|
|
public function register() |
|
23
|
|
|
{ |
|
24
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/multicoin.php', 'multicoin'); |
|
25
|
|
|
|
|
26
|
|
|
$this->registerAliases(); |
|
27
|
|
|
$this->registerFactory(); |
|
28
|
|
|
$this->registerClient(); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Register aliases. |
|
33
|
|
|
* |
|
34
|
|
|
* @return void |
|
35
|
|
|
*/ |
|
36
|
|
|
protected function registerAliases() |
|
37
|
|
|
{ |
|
38
|
|
|
$aliases = [ |
|
39
|
|
|
'multicoin' => 'Multicoin\Api\multicoinFactory', |
|
40
|
|
|
'multicoin.currency' => 'Multicoin\Api\multicoin', |
|
41
|
|
|
]; |
|
42
|
|
|
|
|
43
|
|
|
foreach ($aliases as $key => $aliases) { |
|
44
|
|
|
foreach ((array) $aliases as $alias) { |
|
45
|
|
|
$this->app->alias($key, $alias); |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Register client shortcut. |
|
52
|
|
|
* |
|
53
|
|
|
* @return void |
|
54
|
|
|
*/ |
|
55
|
|
|
protected function registerClient() |
|
56
|
|
|
{ |
|
57
|
|
|
$this->app->bind('multicoin.currency', function ($app) { |
|
58
|
|
|
return $app['multicoin']->currency(); |
|
59
|
|
|
}); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Register client factory. |
|
64
|
|
|
* |
|
65
|
|
|
* @return void |
|
66
|
|
|
*/ |
|
67
|
|
|
protected function registerFactory() |
|
68
|
|
|
{ |
|
69
|
|
|
$this->app->singleton('multicoin', function ($app) { |
|
|
|
|
|
|
70
|
|
|
return new MulticoinFactory(config('multicoin')); |
|
71
|
|
|
}); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
private function registerPublishing() |
|
75
|
|
|
{ |
|
76
|
|
|
if ($this->app->runningInConsole()) { |
|
77
|
|
|
$this->publishes([ |
|
78
|
|
|
__DIR__.'/../config/multicoin.php' => config_path('multicoin.php'), |
|
79
|
|
|
], 'config'); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
private function registerRoutes() |
|
84
|
|
|
{ |
|
85
|
|
|
Route::macro('multicoinWebhook', function ($url) { |
|
86
|
|
|
return Route::any($url, '\Multicoin\Api\Http\Controllers\WebhookController'); |
|
87
|
|
|
}); |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.