1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sausin\Signere; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Route; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
use Illuminate\Contracts\Events\Dispatcher; |
8
|
|
|
|
9
|
|
|
class SignereServiceProvider extends ServiceProvider |
10
|
|
|
{ |
11
|
|
|
use EventMap; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Bootstrap the application services. |
15
|
|
|
* |
16
|
|
|
* @return void |
17
|
|
|
*/ |
18
|
47 |
|
public function boot() |
19
|
|
|
{ |
20
|
|
|
// $this->registerEvents(); |
|
|
|
|
21
|
47 |
|
$this->registerRoutes(); |
22
|
47 |
|
$this->defineAssetPublishing(); |
23
|
47 |
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Register the Signere job events. |
27
|
|
|
* |
28
|
|
|
* @return void |
29
|
|
|
*/ |
30
|
|
|
protected function registerEvents() |
31
|
|
|
{ |
32
|
|
|
$events = $this->app->make(Dispatcher::class); |
33
|
|
|
|
34
|
|
|
foreach ($this->events as $event => $listeners) { |
35
|
|
|
foreach ($listeners as $listener) { |
36
|
|
|
$events->listen($event, $listener); |
37
|
|
|
} |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Register the Signere routes. |
43
|
|
|
* |
44
|
|
|
* @return void |
45
|
|
|
*/ |
46
|
47 |
|
protected function registerRoutes() |
47
|
|
|
{ |
48
|
47 |
|
Route::group([ |
49
|
47 |
|
'prefix' => 'signere', |
50
|
|
|
'namespace' => 'Sausin\Signere\Http\Controllers', |
51
|
|
|
'middleware' => 'web', |
52
|
47 |
|
], function () { |
53
|
47 |
|
$this->loadRoutesFrom(__DIR__.'/../routes/api.php'); |
54
|
47 |
|
}); |
55
|
47 |
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Define the asset publishing configuration. |
59
|
|
|
* |
60
|
|
|
* @return void |
61
|
|
|
*/ |
62
|
47 |
|
public function defineAssetPublishing() |
63
|
|
|
{ |
64
|
47 |
|
$this->publishes([ |
65
|
47 |
|
SIGNERE_PATH.'/public' => public_path('vendor/signere'), |
66
|
47 |
|
], 'signere-assets'); |
67
|
47 |
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Register any application services. |
71
|
|
|
* |
72
|
|
|
* @return void |
73
|
|
|
*/ |
74
|
47 |
|
public function register() |
75
|
|
|
{ |
76
|
47 |
|
if (! defined('SIGNERE_PATH')) { |
77
|
1 |
|
define('SIGNERE_PATH', realpath(__DIR__.'/../')); |
78
|
|
|
} |
79
|
|
|
|
80
|
47 |
|
$this->registerFacades(); |
81
|
47 |
|
$this->configure(); |
82
|
47 |
|
$this->offerPublishing(); |
83
|
47 |
|
} |
84
|
|
|
|
85
|
|
|
protected function registerFacades() |
86
|
|
|
{ |
87
|
47 |
|
$this->app->bind('signere-headers', function () { |
88
|
1 |
|
return new Headers(config()); |
89
|
47 |
|
}); |
90
|
|
|
|
91
|
|
|
// get the environment of the application |
92
|
47 |
|
$env = is_null(config('signere.mode')) ? $this->app->environment() : config('signere.mode'); |
|
|
|
|
93
|
|
|
|
94
|
47 |
|
$this->app->bind('signere-api-key', function ($app, $env) { |
95
|
1 |
|
return new ApiKey($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $env); |
96
|
47 |
|
}); |
97
|
|
|
// $this->app->bind('signere-document', function ($app, $env) { |
|
|
|
|
98
|
|
|
// return new Document($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $env); |
|
|
|
|
99
|
|
|
// }); |
100
|
|
|
// $this->app->bind('signere-document-convert', function ($app, $env) { |
|
|
|
|
101
|
|
|
// return new DocumentConvert($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $env); |
|
|
|
|
102
|
|
|
// }); |
103
|
|
|
// $this->app->bind('signere-document-file', function ($app, $env) { |
|
|
|
|
104
|
|
|
// return new DocumentFile($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $env); |
|
|
|
|
105
|
|
|
// }); |
106
|
|
|
// $this->app->bind('signere-document-job', function ($app, $env) { |
|
|
|
|
107
|
|
|
// return new DocumentJob($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $env); |
|
|
|
|
108
|
|
|
// }); |
109
|
|
|
// $this->app->bind('signere-document-provider', function ($app, $env) { |
|
|
|
|
110
|
|
|
// return new DocumentProvider($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $env); |
|
|
|
|
111
|
|
|
// }); |
112
|
|
|
// $this->app->bind('signere-events', function ($app, $env) { |
|
|
|
|
113
|
|
|
// return new Events($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $env); |
|
|
|
|
114
|
|
|
// }); |
115
|
|
|
// $this->app->bind('signere-external-login', function ($app, $env) { |
|
|
|
|
116
|
|
|
// return new ExternalLogin($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $env); |
|
|
|
|
117
|
|
|
// }); |
118
|
|
|
// $this->app->bind('signere-external-sign', function ($app, $env) { |
|
|
|
|
119
|
|
|
// return new ExternalSign($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $env); |
|
|
|
|
120
|
|
|
// }); |
121
|
|
|
// $this->app->bind('signere-form', function ($app, $env) { |
|
|
|
|
122
|
|
|
// return new Form($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $env); |
|
|
|
|
123
|
|
|
// }); |
124
|
|
|
// $this->app->bind('signere-invoice', function ($app, $env) { |
|
|
|
|
125
|
|
|
// return new Invoice($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $env); |
|
|
|
|
126
|
|
|
// }); |
127
|
|
|
// $this->app->bind('signere-message', function ($app, $env) { |
|
|
|
|
128
|
|
|
// return new Message($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $env); |
|
|
|
|
129
|
|
|
// }); |
130
|
|
|
// $this->app->bind('signere-receiver', function ($app, $env) { |
|
|
|
|
131
|
|
|
// return new Receiver($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $env); |
|
|
|
|
132
|
|
|
// }); |
133
|
|
|
// $this->app->bind('signere-statistics', function ($app, $env) { |
|
|
|
|
134
|
|
|
// return new Statistics($app->make('GuzzleHttp\Client'), $app->make(Headers::class), $env); |
|
|
|
|
135
|
|
|
// }); |
136
|
47 |
|
$this->app->bind('signere-status', function ($app, $env) { |
137
|
1 |
|
return new Status($app->make('GuzzleHttp\Client'), $app->make(Headers::class), config(), $env); |
138
|
47 |
|
}); |
139
|
|
|
|
140
|
47 |
|
$this->app->alias('signere-headers', Facades\SignereHeaders::class); |
141
|
47 |
|
$this->app->alias('signere-api-key', Facades\SignereApiKey::class); |
142
|
|
|
// $this->app->alias('signere-document', Facades\SignereDocument::class); |
|
|
|
|
143
|
|
|
// $this->app->alias('signere-document-convert', Facades\SignereDocumentConvert::class); |
|
|
|
|
144
|
|
|
// $this->app->alias('signere-document-file', Facades\SignereDocumentFile::class); |
|
|
|
|
145
|
|
|
// $this->app->alias('signere-document-job', Facades\SignereDocumentJob::class); |
|
|
|
|
146
|
|
|
// $this->app->alias('signere-document-provider', Facades\SignereDocumentProvider::class); |
|
|
|
|
147
|
|
|
// $this->app->alias('signere-events', Facades\SignereEvents::class); |
|
|
|
|
148
|
|
|
// $this->app->alias('signere-external-login', Facades\SignereExternalLogin::class); |
|
|
|
|
149
|
|
|
// $this->app->alias('signere-external-sign', Facades\SignereExternalSign::class); |
|
|
|
|
150
|
|
|
// $this->app->alias('signere-form', Facades\SignereForm::class); |
|
|
|
|
151
|
|
|
// $this->app->alias('signere-invoice', Facades\SignereInvoice::class); |
|
|
|
|
152
|
|
|
// $this->app->alias('signere-message', Facades\SignereMessage::class); |
|
|
|
|
153
|
|
|
// $this->app->alias('signere-receiver', Facades\SignereReceiver::class); |
|
|
|
|
154
|
|
|
// $this->app->alias('signere-statistics', Facades\SignereStatistics::class); |
|
|
|
|
155
|
47 |
|
$this->app->alias('signere-status', Facades\SignereStatus::class); |
156
|
47 |
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Setup the configuration for Signere. |
160
|
|
|
* |
161
|
|
|
* @return void |
162
|
|
|
*/ |
163
|
47 |
|
protected function configure() |
164
|
|
|
{ |
165
|
47 |
|
$this->mergeConfigFrom( |
166
|
47 |
|
__DIR__.'/../config/signere.php', |
167
|
47 |
|
'signere' |
168
|
|
|
); |
169
|
47 |
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Setup the resource publishing groups for Signere. |
173
|
|
|
* |
174
|
|
|
* @return void |
175
|
|
|
*/ |
176
|
47 |
|
protected function offerPublishing() |
177
|
|
|
{ |
178
|
47 |
|
if ($this->app->runningInConsole()) { |
179
|
47 |
|
$this->publishes([ |
180
|
47 |
|
__DIR__.'/../config/signere.php' => config_path('signere.php'), |
181
|
47 |
|
], 'signere-config'); |
182
|
|
|
} |
183
|
47 |
|
} |
184
|
|
|
} |
185
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.