1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Signifly\Responder; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use Signifly\Responder\Contracts\ModelResolver as ModelResolverContract; |
7
|
|
|
use Signifly\Responder\Contracts\ResourceResolver as ResourceResolverContract; |
8
|
|
|
use Signifly\Responder\Contracts\Responder as ResponderContract; |
9
|
|
|
use Signifly\Responder\Support\ModelResolver; |
10
|
|
|
use Signifly\Responder\Support\ResourceResolver; |
11
|
|
|
|
12
|
|
|
class ResponderServiceProvider extends ServiceProvider |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Bootstrap the application services. |
16
|
|
|
* |
17
|
|
|
* @return void |
18
|
|
|
*/ |
19
|
|
|
public function boot() |
20
|
|
|
{ |
21
|
|
|
if ($this->app->runningInConsole()) { |
22
|
|
|
$this->publishConfigs(); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/responder.php', 'responder'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Register the service provider. |
30
|
|
|
* |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
|
|
public function register() |
34
|
|
|
{ |
35
|
|
|
$this->app->singleton(ResponderContract::class, function ($app) { |
36
|
|
|
return new Responder( |
37
|
|
|
$app->make(ModelResolver::class), |
38
|
|
|
$app->make(ResourceResolver::class) |
39
|
|
|
); |
40
|
|
|
}); |
41
|
|
|
|
42
|
|
|
$this->app->singleton(ModelResolverContract::class, function ($app) { |
|
|
|
|
43
|
|
|
return new ModelResolver(); |
44
|
|
|
}); |
45
|
|
|
|
46
|
|
|
$this->app->singleton(ResourceResolverContract::class, function ($app) { |
|
|
|
|
47
|
|
|
return new ResourceResolver(); |
48
|
|
|
}); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Get the services provided by the provider. |
53
|
|
|
* |
54
|
|
|
* @return array |
55
|
|
|
*/ |
56
|
|
|
public function provides() |
57
|
|
|
{ |
58
|
|
|
return [ |
59
|
|
|
ResponderContract::class, |
60
|
|
|
ModelResolverContract::class, |
61
|
|
|
ResourceResolverContract::class, |
62
|
|
|
]; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
protected function publishConfigs(): void |
66
|
|
|
{ |
67
|
|
|
$this->publishes([ |
68
|
|
|
__DIR__.'/../config/responder.php' => config_path('responder.php'), |
69
|
|
|
], 'responder-config'); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.