1 | <?php |
||
16 | class WebService implements WebServiceInterface |
||
17 | { |
||
18 | |||
19 | use EventDispatcherTrait; |
||
20 | |||
21 | public const EVENT_SUCCESS = 'success'; |
||
22 | public const EVENT_FAILURE = 'failure'; |
||
23 | |||
24 | /** |
||
25 | * základní údaje volané při každém požadavku |
||
26 | * ID_Application, ID_Login |
||
27 | * |
||
28 | * @var array<string, mixed> |
||
29 | */ |
||
30 | protected $init; |
||
31 | |||
32 | /** |
||
33 | * @var SoapClient |
||
34 | */ |
||
35 | protected $soapClient; |
||
36 | |||
37 | /** |
||
38 | * @param array<string, mixed> $soapOpts Nastaveni SOAP requestu |
||
39 | * @throws InvalidArgumentException pokud je odkaz na WSDL soubor prázdný |
||
40 | */ |
||
41 | 3 | public function __construct(SoapClient $soapClient, array $soapOpts) |
|
42 | { |
||
43 | 3 | $this->init = $soapOpts; |
|
44 | 3 | $this->soapClient = $soapClient; |
|
45 | 3 | } |
|
46 | |||
47 | /** |
||
48 | * @inheritdoc |
||
49 | */ |
||
50 | 2 | public function call(string $functionName, array $arguments = []) |
|
51 | { |
||
52 | 2 | return $this->soapCall($functionName, $arguments); |
|
53 | } |
||
54 | |||
55 | |||
56 | /** |
||
57 | * @inheritdoc |
||
58 | */ |
||
59 | 1 | public function __call(string $functionName, array $arguments) |
|
60 | { |
||
61 | 1 | return $this->call($functionName, $arguments); |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * Metoda provadejici SOAP pozadavek na servery Skautisu |
||
66 | * |
||
67 | * @see http://php.net/manual/en/soapclient.soapcall.php |
||
68 | * |
||
69 | * @param string $functionName Nazev akce k provedeni na WebService |
||
70 | * @param array<int|string, mixed> $arguments ([0]=args [1]=cover) |
||
71 | * @param array<string, mixed> $options Nastaveni |
||
72 | * @param array<int, string> $inputHeaders Hlavicky pouzite pri odesilani |
||
73 | * @param array<int, string> $outputHeaders Hlavicky ktere prijdou s odpovedi |
||
74 | * @return mixed |
||
75 | */ |
||
76 | 2 | protected function soapCall( |
|
107 | |||
108 | /** |
||
109 | * Z defaultnich parametru a parametru callu vytvori argumenty pro SoapClient::__soapCall |
||
110 | * |
||
111 | * @param string $functionName Jmeno funkce volane pres SOAP |
||
112 | * @param array<int|string, mixed> $arguments Argumenty k mergnuti s defaultnimy |
||
113 | * |
||
114 | * @return array<int, mixed> Argumenty pro SoapClient::__soapCall |
||
|
|||
115 | */ |
||
116 | 2 | protected function prepareArgs(string $functionName, array $arguments): array |
|
117 | { |
||
118 | 2 | if (!isset($arguments[0]) || !is_array($arguments[0])) { |
|
119 | 2 | $arguments[0] = []; |
|
120 | } |
||
121 | |||
122 | //k argumentum připoji vlastni informace o aplikaci a uzivateli |
||
123 | 2 | $args = array_merge($this->init, $arguments[0]); |
|
124 | |||
125 | 2 | if (!isset($arguments[1])) { |
|
126 | 2 | $functionName = lcfirst($functionName); |
|
127 | 2 | $args = [[$functionName . 'Input' => $args]]; |
|
128 | 2 | return $args; |
|
129 | } |
||
130 | |||
131 | //pokud je zadan druhy parametr tak lze prejmenovat obal dat |
||
132 | $matches = explode('/', $arguments[1]); |
||
133 | //pole se budou vytvaret zevnitr ven |
||
134 | $matches = array_reverse($matches); |
||
135 | |||
136 | $matches[] = 0; //zakladni obal 0=>... |
||
137 | |||
138 | foreach ($matches as $value) { |
||
139 | $args = [$value => $args]; |
||
140 | } |
||
141 | |||
142 | return $args; |
||
143 | } |
||
144 | |||
145 | /** |
||
146 | * Parsuje output ze SoapClient do jednotného formátu |
||
147 | * |
||
148 | * @param string $fname Jméno funkce volané přes SOAP |
||
149 | * @param mixed $ret Odpoveď ze SoapClient::__soapCall |
||
150 | * |
||
151 | * @return array<int|string, mixed> |
||
152 | */ |
||
153 | protected function parseOutput(string $fname, $ret): array |
||
172 | |||
173 | 2 | private function convertToSkautisException(SoapFault $e): WsdlException |
|
185 | } |
||
186 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.