|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace WebservicesNl\Protocol\Soap\Client; |
|
4
|
|
|
|
|
5
|
|
|
use WebservicesNl\Common\Config\ConfigInterface; |
|
6
|
|
|
use WebservicesNl\Platform\PlatformConfigInterface; |
|
7
|
|
|
use WebservicesNl\Protocol\Soap\Exception\ConverterInterface; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Class SoapConfig. |
|
11
|
|
|
* |
|
12
|
|
|
* Soap config object that holds all data for a specific SOAP connection |
|
13
|
|
|
*/ |
|
14
|
|
|
class SoapConfig implements ConfigInterface |
|
15
|
|
|
{ |
|
16
|
|
|
const DEFAULT_RESPONSE_TIMEOUT = 20; |
|
17
|
|
|
const RETRY_MINUTES = 60; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var ConverterInterface |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $converter; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* List with Soap Server endpoints for platform. |
|
26
|
|
|
* |
|
27
|
|
|
* @var array |
|
28
|
|
|
*/ |
|
29
|
|
|
protected static $endPoints = []; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var PlatformConfigInterface |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $platformConfig; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var array |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $soapHeaders = []; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* SoapConfig constructor. |
|
43
|
|
|
* |
|
44
|
|
|
* @param PlatformConfigInterface $config |
|
45
|
|
|
*/ |
|
46
|
12 |
|
public function __construct(PlatformConfigInterface $config) |
|
47
|
|
|
{ |
|
48
|
12 |
|
$this->platformConfig = $config; |
|
49
|
12 |
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Returns configured instance. |
|
53
|
|
|
* |
|
54
|
|
|
* @param PlatformConfigInterface $config |
|
55
|
|
|
* |
|
56
|
|
|
* @return SoapConfig |
|
57
|
|
|
*/ |
|
58
|
12 |
|
public static function configure($config) |
|
59
|
|
|
{ |
|
60
|
12 |
|
return new static($config); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @return ConverterInterface |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function getConverter() |
|
67
|
|
|
{ |
|
68
|
1 |
|
return $this->converter; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Return array with Endpoints. |
|
73
|
|
|
* |
|
74
|
|
|
* @return array |
|
75
|
|
|
*/ |
|
76
|
8 |
|
public static function getEndPoints() |
|
77
|
|
|
{ |
|
78
|
8 |
|
return static::$endPoints; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @return PlatformConfigInterface |
|
83
|
|
|
*/ |
|
84
|
1 |
|
public function getPlatformConfig() |
|
85
|
|
|
{ |
|
86
|
1 |
|
return $this->platformConfig; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @return array |
|
91
|
|
|
*/ |
|
92
|
1 |
|
public function getSoapHeaders() |
|
93
|
|
|
{ |
|
94
|
1 |
|
return $this->soapHeaders; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @return bool |
|
99
|
|
|
*/ |
|
100
|
8 |
|
public function hasConverter() |
|
101
|
|
|
{ |
|
102
|
8 |
|
return $this->converter instanceof ConverterInterface; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Return config as an array. |
|
107
|
|
|
* |
|
108
|
|
|
* @return array |
|
109
|
|
|
*/ |
|
110
|
1 |
|
public function toArray() |
|
111
|
|
|
{ |
|
112
|
|
|
return [ |
|
113
|
1 |
|
'converter' => $this->getConverter(), |
|
114
|
1 |
|
'endpoints' => static::$endPoints, |
|
115
|
1 |
|
'platformConfig' => $this->platformConfig->toArray(), |
|
116
|
1 |
|
'retry_minutes' => static::DEFAULT_RESPONSE_TIMEOUT, |
|
117
|
1 |
|
'soap_headers' => (array)$this->getSoapHeaders(), |
|
118
|
1 |
|
]; |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
|