1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ElfSundae\Laravel\Api; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use Laravel\Lumen\Application as LumenApplication; |
|
|
|
|
7
|
|
|
|
8
|
|
|
class ApiServiceProvider extends ServiceProvider |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Register the service provider. |
12
|
|
|
* |
13
|
|
|
* @return void |
14
|
|
|
*/ |
15
|
|
|
public function register() |
16
|
|
|
{ |
17
|
|
|
if ($this->app instanceof LumenApplication) { |
18
|
|
|
$this->app->configure('api'); // @codeCoverageIgnore |
|
|
|
|
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/api.php', 'api'); |
22
|
|
|
|
23
|
|
|
$this->registerClient(); |
24
|
|
|
|
25
|
|
|
$this->registerToken(); |
26
|
|
|
|
27
|
|
|
if ($this->app->runningInConsole()) { |
|
|
|
|
28
|
|
|
$this->registerForConsole(); |
29
|
|
|
} |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Register the Client singleton. |
34
|
|
|
* |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
|
|
protected function registerClient() |
38
|
|
|
{ |
39
|
|
|
$this->app->singleton('api.client', function ($app) { |
40
|
|
|
$client = new Client( |
41
|
|
|
$app['encrypter'], |
42
|
|
|
$app['config']->get('api.clients', []) |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
$client->setDefaultAppKey($app['config']->get('api.default_client')); |
46
|
|
|
|
47
|
|
|
return $client; |
48
|
|
|
}); |
49
|
|
|
|
50
|
|
|
$this->app->alias('api.client', Client::class); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Register the Token singleton. |
55
|
|
|
* |
56
|
|
|
* @return void |
57
|
|
|
*/ |
58
|
|
|
protected function registerToken() |
59
|
|
|
{ |
60
|
|
|
$this->app->singleton('api.token', function ($app) { |
61
|
|
|
return new Token($app['api.client']); |
62
|
|
|
}); |
63
|
|
|
|
64
|
|
|
$this->app->alias('api.token', Token::class); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Register for console. |
69
|
|
|
* |
70
|
|
|
* @return void |
71
|
|
|
*/ |
72
|
|
|
protected function registerForConsole() |
73
|
|
|
{ |
74
|
|
|
$this->publishes([ |
75
|
|
|
__DIR__.'/../config/api.php' => base_path('config/api.php'), |
|
|
|
|
76
|
|
|
], 'laravel-api'); |
77
|
|
|
|
78
|
|
|
$this->commands([ |
79
|
|
|
Console\GenerateClientCommand::class, |
80
|
|
|
Console\GenerateTokenCommand::class, |
81
|
|
|
]); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths