|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Spinen\Ncentral\Laravel; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Contracts\Foundation\Application; |
|
6
|
|
|
use Illuminate\Support\ServiceProvider as LaravelServiceProvider; |
|
7
|
|
|
use Spinen\Ncentral\NcentralClient; |
|
8
|
|
|
use Spinen\Ncentral\NcentralClientFactory; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class NcentralProvider |
|
12
|
|
|
* |
|
13
|
|
|
* @package Spinen\Ncentral\Laravel |
|
14
|
|
|
*/ |
|
15
|
|
|
class ServiceProvider extends LaravelServiceProvider |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* Indicates if loading of the provider is deferred. |
|
19
|
|
|
* |
|
20
|
|
|
* @var bool |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $defer = true; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Bootstrap the application services. |
|
26
|
|
|
* |
|
27
|
|
|
* @return void |
|
28
|
|
|
*/ |
|
29
|
|
|
public function boot() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->registerNcentralClient(); |
|
32
|
|
|
|
|
33
|
|
|
$this->registerPublishes(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Register the application services. |
|
38
|
|
|
* |
|
39
|
|
|
* @return void |
|
40
|
|
|
*/ |
|
41
|
|
|
public function register() |
|
42
|
|
|
{ |
|
43
|
|
|
$this->app->alias(NcentralClient::class, 'ncentral'); |
|
44
|
|
|
|
|
45
|
|
|
$this->mergeConfigFrom(__DIR__ . '/../../config/clickup.php', 'clickup'); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Register the NcentralClient object |
|
50
|
|
|
* |
|
51
|
|
|
* A NcentralClient needs to have some properties set, so in Laravel, we are going to pull them from the configs. |
|
52
|
|
|
*/ |
|
53
|
|
|
protected function registerNcentralClient() |
|
54
|
|
|
{ |
|
55
|
|
|
$this->app->singleton( |
|
56
|
|
|
NcentralClient::class, |
|
57
|
|
|
function (Application $app) { |
|
|
|
|
|
|
58
|
|
|
return NcentralClientFactory::factory(env('NCENTRAL_WSDL_PATH')); |
|
59
|
|
|
} |
|
60
|
|
|
); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* There are several resources that get published |
|
65
|
|
|
* |
|
66
|
|
|
* Only worry about telling the application about them if running in the console. |
|
67
|
|
|
*/ |
|
68
|
|
|
protected function registerPublishes() |
|
69
|
|
|
{ |
|
70
|
|
|
if ($this->app->runningInConsole()) { |
|
71
|
|
|
$this->publishes( |
|
72
|
|
|
[ |
|
73
|
|
|
__DIR__ . '/../../config/soap-client.php' => config_path('soap-client.php'), |
|
|
|
|
|
|
74
|
|
|
], |
|
75
|
|
|
'soap-client' |
|
76
|
|
|
); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Get the services provided by the provider. |
|
82
|
|
|
* |
|
83
|
|
|
* @return array |
|
84
|
|
|
*/ |
|
85
|
|
|
public function provides() |
|
86
|
|
|
{ |
|
87
|
|
|
return [ |
|
88
|
|
|
NcentralClient::class, |
|
89
|
|
|
]; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.