1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WsdlToPhp\PackageGenerator\Generator; |
4
|
|
|
|
5
|
|
|
use WsdlToPhp\PackageGenerator\Model\Schema; |
6
|
|
|
use WsdlToPhp\PackageGenerator\Model\Wsdl; |
7
|
|
|
use WsdlToPhp\PackageGenerator\Model\AbstractModel; |
8
|
|
|
use WsdlToPhp\PackageGenerator\Model\EmptyModel; |
9
|
|
|
use WsdlToPhp\PackageGenerator\Model\Struct; |
10
|
|
|
use WsdlToPhp\PackageGenerator\Model\Service; |
11
|
|
|
use WsdlToPhp\PackageGenerator\Model\Method; |
12
|
|
|
use WsdlToPhp\PackageGenerator\Container\Model\Service as ServiceContainer; |
13
|
|
|
use WsdlToPhp\PackageGenerator\Container\Model\Struct as StructContainer; |
14
|
|
|
use WsdlToPhp\PackageGenerator\ConfigurationReader\GeneratorOptions; |
15
|
|
|
use WsdlToPhp\PackageGenerator\DomHandler\Wsdl\Wsdl as WsdlDocument; |
16
|
|
|
|
17
|
|
|
class Generator |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Wsdl |
21
|
|
|
* @var Wsdl |
22
|
|
|
*/ |
23
|
|
|
private $wsdl; |
24
|
|
|
/** |
25
|
|
|
* @var GeneratorOptions |
26
|
|
|
*/ |
27
|
|
|
private $options; |
28
|
|
|
/** |
29
|
|
|
* Used parsers |
30
|
|
|
* @var GeneratorParsers |
31
|
|
|
*/ |
32
|
|
|
private $parsers; |
33
|
|
|
/** |
34
|
|
|
* Used files |
35
|
|
|
* @var GeneratorFiles |
36
|
|
|
*/ |
37
|
|
|
private $files; |
38
|
|
|
/** |
39
|
|
|
* Used containers |
40
|
|
|
* @var GeneratorContainers |
41
|
|
|
*/ |
42
|
|
|
private $containers; |
43
|
|
|
/** |
44
|
|
|
* Used SoapClient |
45
|
|
|
* @var GeneratorSoapClient |
46
|
|
|
*/ |
47
|
|
|
private $soapClient; |
48
|
|
|
/** |
49
|
|
|
* Constructor |
50
|
|
|
* @param GeneratorOptions $options |
51
|
|
|
*/ |
52
|
412 |
|
public function __construct(GeneratorOptions $options) |
53
|
|
|
{ |
54
|
309 |
|
$this |
55
|
412 |
|
->setOptions($options) |
56
|
412 |
|
->initialize(); |
57
|
400 |
|
} |
58
|
|
|
/** |
59
|
|
|
* @return Generator |
60
|
|
|
*/ |
61
|
412 |
|
protected function initialize() |
62
|
|
|
{ |
63
|
309 |
|
return $this |
64
|
412 |
|
->initContainers() |
65
|
412 |
|
->initParsers() |
66
|
412 |
|
->initFiles() |
67
|
412 |
|
->initWsdl() |
68
|
404 |
|
->initSoapClient(); |
69
|
15 |
|
} |
70
|
|
|
/** |
71
|
|
|
* @throws \InvalidArgumentException |
72
|
|
|
* @return Generator |
73
|
|
|
*/ |
74
|
404 |
|
protected function initSoapClient() |
75
|
|
|
{ |
76
|
404 |
|
if (!isset($this->soapClient)) { |
77
|
404 |
|
$this->soapClient = new GeneratorSoapClient($this); |
78
|
300 |
|
} |
79
|
400 |
|
return $this; |
80
|
|
|
} |
81
|
|
|
/** |
82
|
|
|
* @return Generator |
83
|
|
|
*/ |
84
|
412 |
|
protected function initContainers() |
85
|
|
|
{ |
86
|
412 |
|
if (!isset($this->containers)) { |
87
|
412 |
|
$this->containers = new GeneratorContainers($this); |
88
|
309 |
|
} |
89
|
412 |
|
return $this; |
90
|
|
|
} |
91
|
|
|
/** |
92
|
|
|
* @return Generator |
93
|
|
|
*/ |
94
|
412 |
|
protected function initParsers() |
95
|
|
|
{ |
96
|
412 |
|
if (!isset($this->parsers)) { |
97
|
412 |
|
$this->parsers = new GeneratorParsers($this); |
98
|
309 |
|
} |
99
|
412 |
|
return $this; |
100
|
|
|
} |
101
|
|
|
/** |
102
|
|
|
* @return Generator |
103
|
|
|
*/ |
104
|
412 |
|
protected function initFiles() |
105
|
|
|
{ |
106
|
412 |
|
if (!isset($this->files)) { |
107
|
412 |
|
$this->files = new GeneratorFiles($this); |
108
|
309 |
|
} |
109
|
412 |
|
return $this; |
110
|
|
|
} |
111
|
|
|
/** |
112
|
|
|
* @return GeneratorFiles |
113
|
|
|
*/ |
114
|
44 |
|
public function getFiles() |
115
|
|
|
{ |
116
|
44 |
|
return $this->files; |
117
|
|
|
} |
118
|
|
|
/** |
119
|
|
|
* @throws \InvalidArgumentException |
120
|
|
|
* @return Generator |
121
|
|
|
*/ |
122
|
24 |
|
protected function initDirectory() |
123
|
|
|
{ |
124
|
24 |
|
Utils::createDirectory($this->getOptions()->getDestination()); |
125
|
24 |
|
if (!is_writable($this->getOptionDestination())) { |
126
|
4 |
|
throw new \InvalidArgumentException(sprintf('Unable to use dir "%s" as dir does not exists, its creation has been impossible or it\'s not writable', $this->getOptionDestination()), __LINE__); |
127
|
|
|
} |
128
|
20 |
|
return $this; |
129
|
|
|
} |
130
|
|
|
/** |
131
|
|
|
* @return Generator |
132
|
|
|
*/ |
133
|
416 |
|
protected function initWsdl() |
134
|
|
|
{ |
135
|
416 |
|
$this->setWsdl(new Wsdl($this, $this->getOptionOrigin(), $this->getUrlContent($this->getOptionOrigin()))); |
136
|
408 |
|
return $this; |
137
|
|
|
} |
138
|
|
|
/** |
139
|
|
|
* @return Generator |
140
|
|
|
*/ |
141
|
28 |
|
protected function doSanityChecks() |
142
|
|
|
{ |
143
|
28 |
|
$destination = $this->getOptionDestination(); |
144
|
28 |
|
if (empty($destination)) { |
145
|
|
|
throw new \InvalidArgumentException('Package\'s destination must be defined', __LINE__); |
146
|
|
|
} |
147
|
28 |
|
$composerName = $this->getOptionComposerName(); |
148
|
28 |
|
if (empty($composerName)) { |
149
|
4 |
|
throw new \InvalidArgumentException('Package\'s composer name must be defined', __LINE__); |
150
|
|
|
} |
151
|
24 |
|
return $this; |
152
|
|
|
} |
153
|
|
|
/** |
154
|
|
|
* @return Generator |
155
|
|
|
*/ |
156
|
20 |
|
protected function doParse() |
157
|
|
|
{ |
158
|
20 |
|
$this->parsers->doParse(); |
159
|
20 |
|
return $this; |
160
|
|
|
} |
161
|
|
|
/** |
162
|
|
|
* @return Generator |
163
|
|
|
*/ |
164
|
20 |
|
protected function doGenerate() |
165
|
|
|
{ |
166
|
20 |
|
$this->files->doGenerate(); |
167
|
20 |
|
return $this; |
168
|
|
|
} |
169
|
|
|
/** |
170
|
|
|
* Generates all classes based on options |
171
|
|
|
* @return Generator |
172
|
|
|
*/ |
173
|
28 |
|
public function generatePackage() |
174
|
|
|
{ |
175
|
21 |
|
return $this |
176
|
28 |
|
->doSanityChecks() |
177
|
24 |
|
->initDirectory() |
178
|
20 |
|
->doParse() |
179
|
20 |
|
->doGenerate(); |
180
|
|
|
} |
181
|
|
|
/** |
182
|
|
|
* Gets the struct by its name |
183
|
|
|
* @uses Generator::getStructs() |
184
|
|
|
* @param string $structName the original struct name |
185
|
|
|
* @return Struct|null |
186
|
|
|
*/ |
187
|
304 |
|
public function getStruct($structName) |
188
|
|
|
{ |
189
|
304 |
|
return $this->getStructs()->getStructByName($structName); |
190
|
|
|
} |
191
|
|
|
/** |
192
|
|
|
* Gets a service by its name |
193
|
|
|
* @param string $serviceName the service name |
194
|
|
|
* @return Service|null |
195
|
|
|
*/ |
196
|
276 |
|
public function getService($serviceName) |
197
|
|
|
{ |
198
|
276 |
|
return $this->getServices()->getServiceByName($serviceName); |
199
|
|
|
} |
200
|
|
|
/** |
201
|
|
|
* Returns the method |
202
|
|
|
* @uses Generator::getServiceName() |
203
|
|
|
* @uses Generator::getService() |
204
|
|
|
* @uses Service::getMethod() |
205
|
|
|
* @param string $methodName the original function name |
206
|
|
|
* @return Method|null |
207
|
|
|
*/ |
208
|
272 |
|
public function getServiceMethod($methodName) |
209
|
|
|
{ |
210
|
272 |
|
return $this->getService($this->getServiceName($methodName)) instanceof Service ? $this->getService($this->getServiceName($methodName))->getMethod($methodName) : null; |
211
|
|
|
} |
212
|
|
|
/** |
213
|
|
|
* @return ServiceContainer |
214
|
|
|
*/ |
215
|
376 |
|
public function getServices() |
216
|
|
|
{ |
217
|
376 |
|
return $this->containers->getServices(); |
218
|
|
|
} |
219
|
|
|
/** |
220
|
|
|
* @return StructContainer |
221
|
|
|
*/ |
222
|
356 |
|
public function getStructs() |
223
|
|
|
{ |
224
|
356 |
|
return $this->containers->getStructs(); |
225
|
|
|
} |
226
|
|
|
/** |
227
|
|
|
* Sets the optionCategory value |
228
|
|
|
* @return string |
229
|
|
|
*/ |
230
|
220 |
|
public function getOptionCategory() |
231
|
|
|
{ |
232
|
220 |
|
return $this->options->getCategory(); |
233
|
|
|
} |
234
|
|
|
/** |
235
|
|
|
* Sets the optionCategory value |
236
|
|
|
* @param string $category |
237
|
|
|
* @return Generator |
238
|
|
|
*/ |
239
|
216 |
|
public function setOptionCategory($category) |
240
|
|
|
{ |
241
|
216 |
|
$this->options->setCategory($category); |
242
|
216 |
|
return $this; |
243
|
|
|
} |
244
|
|
|
/** |
245
|
|
|
* Sets the optionGatherMethods value |
246
|
|
|
* @return string |
247
|
|
|
*/ |
248
|
384 |
|
public function getOptionGatherMethods() |
249
|
|
|
{ |
250
|
384 |
|
return $this->options->getGatherMethods(); |
251
|
|
|
} |
252
|
|
|
/** |
253
|
|
|
* Sets the optionGatherMethods value |
254
|
|
|
* @param string $gatherMethods |
255
|
|
|
* @return Generator |
256
|
|
|
*/ |
257
|
216 |
|
public function setOptionGatherMethods($gatherMethods) |
258
|
|
|
{ |
259
|
216 |
|
$this->options->setGatherMethods($gatherMethods); |
260
|
216 |
|
return $this; |
261
|
|
|
} |
262
|
|
|
/** |
263
|
|
|
* Gets the optionGenericConstantsNames value |
264
|
|
|
* @return bool |
265
|
|
|
*/ |
266
|
56 |
|
public function getOptionGenericConstantsNames() |
267
|
|
|
{ |
268
|
56 |
|
return $this->options->getGenericConstantsName(); |
269
|
|
|
} |
270
|
|
|
/** |
271
|
|
|
* Sets the optionGenericConstantsNames value |
272
|
|
|
* @param bool $genericConstantsNames |
273
|
|
|
* @return Generator |
274
|
|
|
*/ |
275
|
8 |
|
public function setOptionGenericConstantsNames($genericConstantsNames) |
276
|
|
|
{ |
277
|
8 |
|
$this->options->setGenericConstantsName($genericConstantsNames); |
278
|
8 |
|
return $this; |
279
|
|
|
} |
280
|
|
|
/** |
281
|
|
|
* Gets the optionGenerateTutorialFile value |
282
|
|
|
* @return bool |
283
|
|
|
*/ |
284
|
28 |
|
public function getOptionGenerateTutorialFile() |
285
|
|
|
{ |
286
|
28 |
|
return $this->options->getGenerateTutorialFile(); |
287
|
|
|
} |
288
|
|
|
/** |
289
|
|
|
* Sets the optionGenerateTutorialFile value |
290
|
|
|
* @param bool $generateTutorialFile |
291
|
|
|
* @return Generator |
292
|
|
|
*/ |
293
|
4 |
|
public function setOptionGenerateTutorialFile($generateTutorialFile) |
294
|
|
|
{ |
295
|
4 |
|
$this->options->setGenerateTutorialFile($generateTutorialFile); |
296
|
4 |
|
return $this; |
297
|
|
|
} |
298
|
|
|
/** |
299
|
|
|
* Gets the optionNamespacePrefix value |
300
|
|
|
* @return string |
301
|
|
|
*/ |
302
|
196 |
|
public function getOptionNamespacePrefix() |
303
|
|
|
{ |
304
|
196 |
|
return $this->options->getNamespace(); |
305
|
|
|
} |
306
|
|
|
/** |
307
|
|
|
* Sets the optionGenerateTutorialFile value |
308
|
|
|
* @param string $namespace |
309
|
|
|
* @return Generator |
310
|
|
|
*/ |
311
|
12 |
|
public function setOptionNamespacePrefix($namespace) |
312
|
|
|
{ |
313
|
12 |
|
$this->options->setNamespace($namespace); |
314
|
12 |
|
return $this; |
315
|
|
|
} |
316
|
|
|
/** |
317
|
|
|
* Gets the optionAddComments value |
318
|
|
|
* @return array |
319
|
|
|
*/ |
320
|
156 |
|
public function getOptionAddComments() |
321
|
|
|
{ |
322
|
156 |
|
return $this->options->getAddComments(); |
323
|
|
|
} |
324
|
|
|
/** |
325
|
|
|
* Sets the optionAddComments value |
326
|
|
|
* @param array $addComments |
327
|
|
|
* @return Generator |
328
|
|
|
*/ |
329
|
216 |
|
public function setOptionAddComments($addComments) |
330
|
|
|
{ |
331
|
216 |
|
$this->options->setAddComments($addComments); |
332
|
216 |
|
return $this; |
333
|
|
|
} |
334
|
|
|
/** |
335
|
|
|
* Gets the optionStandalone value |
336
|
|
|
* @return bool |
337
|
|
|
*/ |
338
|
52 |
|
public function getOptionStandalone() |
339
|
|
|
{ |
340
|
52 |
|
return $this->options->getStandalone(); |
341
|
|
|
} |
342
|
|
|
/** |
343
|
|
|
* Sets the optionStandalone value |
344
|
|
|
* @param bool $standalone |
345
|
|
|
* @return Generator |
346
|
|
|
*/ |
347
|
8 |
|
public function setOptionStandalone($standalone) |
348
|
|
|
{ |
349
|
8 |
|
$this->options->setStandalone($standalone); |
350
|
8 |
|
return $this; |
351
|
|
|
} |
352
|
|
|
/** |
353
|
|
|
* Gets the optionStructClass value |
354
|
|
|
* @return string |
355
|
|
|
*/ |
356
|
56 |
|
public function getOptionStructClass() |
357
|
|
|
{ |
358
|
56 |
|
return $this->options->getStructClass(); |
359
|
|
|
} |
360
|
|
|
/** |
361
|
|
|
* Sets the optionStructClass value |
362
|
|
|
* @param string $structClass |
363
|
|
|
* @return Generator |
364
|
|
|
*/ |
365
|
12 |
|
public function setOptionStructClass($structClass) |
366
|
|
|
{ |
367
|
12 |
|
$this->options->setStructClass($structClass); |
368
|
12 |
|
return $this; |
369
|
|
|
} |
370
|
|
|
/** |
371
|
|
|
* Gets the optionStructArrayClass value |
372
|
|
|
* @return string |
373
|
|
|
*/ |
374
|
36 |
|
public function getOptionStructArrayClass() |
375
|
|
|
{ |
376
|
36 |
|
return $this->options->getStructArrayClass(); |
377
|
|
|
} |
378
|
|
|
/** |
379
|
|
|
* Sets the optionStructArrayClass value |
380
|
|
|
* @param string $structArrayClass |
381
|
|
|
* @return Generator |
382
|
|
|
*/ |
383
|
4 |
|
public function setOptionStructArrayClass($structArrayClass) |
384
|
|
|
{ |
385
|
4 |
|
$this->options->setStructArrayClass($structArrayClass); |
386
|
4 |
|
return $this; |
387
|
|
|
} |
388
|
|
|
/** |
389
|
|
|
* Gets the optionSoapClientClass value |
390
|
|
|
* @return string |
391
|
|
|
*/ |
392
|
80 |
|
public function getOptionSoapClientClass() |
393
|
|
|
{ |
394
|
80 |
|
return $this->options->getSoapClientClass(); |
395
|
|
|
} |
396
|
|
|
/** |
397
|
|
|
* Sets the optionSoapClientClass value |
398
|
|
|
* @param string $soapClientClass |
399
|
|
|
* @return Generator |
400
|
|
|
*/ |
401
|
4 |
|
public function setOptionSoapClientClass($soapClientClass) |
402
|
|
|
{ |
403
|
4 |
|
$this->options->setSoapClientClass($soapClientClass); |
404
|
4 |
|
return $this; |
405
|
|
|
} |
406
|
|
|
/** |
407
|
|
|
* Gets the package name prefix |
408
|
|
|
* @param bool $ucFirst ucfirst package name prefix or not |
409
|
|
|
* @return string |
410
|
|
|
*/ |
411
|
440 |
|
public function getOptionPrefix($ucFirst = true) |
412
|
|
|
{ |
413
|
440 |
|
return $ucFirst ? ucfirst($this->getOptions()->getPrefix()) : $this->getOptions()->getPrefix(); |
414
|
|
|
} |
415
|
|
|
/** |
416
|
|
|
* Sets the package name prefix |
417
|
|
|
* @param string $optionPrefix |
418
|
|
|
* @return Generator |
419
|
|
|
*/ |
420
|
236 |
|
public function setOptionPrefix($optionPrefix) |
421
|
|
|
{ |
422
|
236 |
|
$this->options->setPrefix($optionPrefix); |
423
|
236 |
|
return $this; |
424
|
|
|
} |
425
|
|
|
/** |
426
|
|
|
* Gets the package name suffix |
427
|
|
|
* @param bool $ucFirst ucfirst package name suffix or not |
428
|
|
|
* @return string |
429
|
|
|
*/ |
430
|
428 |
|
public function getOptionSuffix($ucFirst = true) |
431
|
|
|
{ |
432
|
428 |
|
return $ucFirst ? ucfirst($this->getOptions()->getSuffix()) : $this->getOptions()->getSuffix(); |
433
|
|
|
} |
434
|
|
|
/** |
435
|
|
|
* Sets the package name suffix |
436
|
|
|
* @param string $optionSuffix |
437
|
|
|
* @return Generator |
438
|
|
|
*/ |
439
|
28 |
|
public function setOptionSuffix($optionSuffix) |
440
|
|
|
{ |
441
|
28 |
|
$this->options->setSuffix($optionSuffix); |
442
|
28 |
|
return $this; |
443
|
|
|
} |
444
|
|
|
/** |
445
|
|
|
* Gets the optionBasicLogin value |
446
|
|
|
* @return string |
447
|
|
|
*/ |
448
|
416 |
|
public function getOptionBasicLogin() |
449
|
|
|
{ |
450
|
416 |
|
return $this->options->getBasicLogin(); |
451
|
|
|
} |
452
|
|
|
/** |
453
|
|
|
* Sets the optionBasicLogin value |
454
|
|
|
* @param string $optionBasicLogin |
455
|
|
|
* @return Generator |
456
|
|
|
*/ |
457
|
4 |
|
public function setOptionBasicLogin($optionBasicLogin) |
458
|
|
|
{ |
459
|
4 |
|
$this->options->setBasicLogin($optionBasicLogin); |
460
|
4 |
|
return $this; |
461
|
|
|
} |
462
|
|
|
/** |
463
|
|
|
* Gets the optionBasicPassword value |
464
|
|
|
* @return string |
465
|
|
|
*/ |
466
|
416 |
|
public function getOptionBasicPassword() |
467
|
|
|
{ |
468
|
416 |
|
return $this->options->getBasicPassword(); |
469
|
|
|
} |
470
|
|
|
/** |
471
|
|
|
* Sets the optionBasicPassword value |
472
|
|
|
* @param string $optionBasicPassword |
473
|
|
|
* @return Generator |
474
|
|
|
*/ |
475
|
4 |
|
public function setOptionBasicPassword($optionBasicPassword) |
476
|
|
|
{ |
477
|
4 |
|
$this->options->setBasicPassword($optionBasicPassword); |
478
|
4 |
|
return $this; |
479
|
|
|
} |
480
|
|
|
/** |
481
|
|
|
* Gets the optionProxyHost value |
482
|
|
|
* @return string |
483
|
|
|
*/ |
484
|
416 |
|
public function getOptionProxyHost() |
485
|
|
|
{ |
486
|
416 |
|
return $this->options->getProxyHost(); |
487
|
|
|
} |
488
|
|
|
/** |
489
|
|
|
* Sets the optionProxyHost value |
490
|
|
|
* @param string $optionProxyHost |
491
|
|
|
* @return Generator |
492
|
|
|
*/ |
493
|
4 |
|
public function setOptionProxyHost($optionProxyHost) |
494
|
|
|
{ |
495
|
4 |
|
$this->options->setProxyHost($optionProxyHost); |
496
|
4 |
|
return $this; |
497
|
|
|
} |
498
|
|
|
/** |
499
|
|
|
* Gets the optionProxyPort value |
500
|
|
|
* @return string |
501
|
|
|
*/ |
502
|
416 |
|
public function getOptionProxyPort() |
503
|
|
|
{ |
504
|
416 |
|
return $this->options->getProxyPort(); |
505
|
|
|
} |
506
|
|
|
/** |
507
|
|
|
* Sets the optionProxyPort value |
508
|
|
|
* @param string $optionProxyPort |
509
|
|
|
* @return Generator |
510
|
|
|
*/ |
511
|
4 |
|
public function setOptionProxyPort($optionProxyPort) |
512
|
|
|
{ |
513
|
4 |
|
$this->options->setProxyPort($optionProxyPort); |
514
|
4 |
|
return $this; |
515
|
|
|
} |
516
|
|
|
/** |
517
|
|
|
* Gets the optionProxyLogin value |
518
|
|
|
* @return string |
519
|
|
|
*/ |
520
|
416 |
|
public function getOptionProxyLogin() |
521
|
|
|
{ |
522
|
416 |
|
return $this->options->getProxyLogin(); |
523
|
|
|
} |
524
|
|
|
/** |
525
|
|
|
* Sets the optionProxyLogin value |
526
|
|
|
* @param string $optionProxyLogin |
527
|
|
|
* @return Generator |
528
|
|
|
*/ |
529
|
4 |
|
public function setOptionProxyLogin($optionProxyLogin) |
530
|
|
|
{ |
531
|
4 |
|
$this->options->setProxyLogin($optionProxyLogin); |
532
|
4 |
|
return $this; |
533
|
|
|
} |
534
|
|
|
/** |
535
|
|
|
* Gets the optionProxyPassword value |
536
|
|
|
* @return string |
537
|
|
|
*/ |
538
|
416 |
|
public function getOptionProxyPassword() |
539
|
|
|
{ |
540
|
416 |
|
return $this->options->getProxyPassword(); |
541
|
|
|
} |
542
|
|
|
/** |
543
|
|
|
* Sets the optionProxyPassword value |
544
|
|
|
* @param string $optionProxyPassword |
545
|
|
|
* @return Generator |
546
|
|
|
*/ |
547
|
4 |
|
public function setOptionProxyPassword($optionProxyPassword) |
548
|
|
|
{ |
549
|
4 |
|
$this->options->setProxyPassword($optionProxyPassword); |
550
|
4 |
|
return $this; |
551
|
|
|
} |
552
|
|
|
/** |
553
|
|
|
* Gets the optionOrigin value |
554
|
|
|
* @return string |
555
|
|
|
*/ |
556
|
420 |
|
public function getOptionOrigin() |
557
|
|
|
{ |
558
|
420 |
|
return $this->options->getOrigin(); |
559
|
|
|
} |
560
|
|
|
/** |
561
|
|
|
* Sets the optionOrigin value |
562
|
|
|
* @param string $optionOrigin |
563
|
|
|
* @return Generator |
564
|
|
|
*/ |
565
|
4 |
|
public function setOptionOrigin($optionOrigin) |
566
|
|
|
{ |
567
|
4 |
|
$this->options->setOrigin($optionOrigin); |
568
|
4 |
|
$this->initWsdl(); |
569
|
4 |
|
return $this; |
570
|
|
|
} |
571
|
|
|
/** |
572
|
|
|
* Gets the optionDestination value |
573
|
|
|
* @return string |
574
|
|
|
*/ |
575
|
232 |
|
public function getOptionDestination() |
576
|
|
|
{ |
577
|
232 |
|
$destination = $this->options->getDestination(); |
578
|
232 |
|
if (!empty($destination)) { |
579
|
232 |
|
$destination = realpath($this->options->getDestination()) . DIRECTORY_SEPARATOR; |
580
|
174 |
|
} |
581
|
232 |
|
return $destination; |
582
|
|
|
} |
583
|
|
|
/** |
584
|
|
|
* Sets the optionDestination value |
585
|
|
|
* @param string $optionDestination |
586
|
|
|
* @return Generator |
587
|
|
|
*/ |
588
|
12 |
|
public function setOptionDestination($optionDestination) |
589
|
|
|
{ |
590
|
12 |
|
if (!empty($optionDestination)) { |
591
|
8 |
|
$this->options->setDestination(realpath($optionDestination) . DIRECTORY_SEPARATOR); |
592
|
6 |
|
} else { |
593
|
4 |
|
throw new \InvalidArgumentException('Package\'s destination can\'t be empty', __LINE__); |
594
|
|
|
} |
595
|
8 |
|
return $this; |
596
|
|
|
} |
597
|
|
|
/** |
598
|
|
|
* Gets the optionSoapOptions value |
599
|
|
|
* @return string |
600
|
|
|
*/ |
601
|
412 |
|
public function getOptionSoapOptions() |
602
|
|
|
{ |
603
|
412 |
|
return $this->options->getSoapOptions(); |
604
|
|
|
} |
605
|
|
|
/** |
606
|
|
|
* Sets the optionSoapOptions value |
607
|
|
|
* @param array $optionSoapOptions |
608
|
|
|
* @return Generator |
609
|
|
|
*/ |
610
|
4 |
|
public function setOptionSoapOptions($optionSoapOptions) |
611
|
|
|
{ |
612
|
4 |
|
$this->options->setSoapOptions($optionSoapOptions); |
613
|
4 |
|
return $this; |
614
|
|
|
} |
615
|
|
|
/** |
616
|
|
|
* Gets the optionComposerName value |
617
|
|
|
* @return string |
618
|
|
|
*/ |
619
|
36 |
|
public function getOptionComposerName() |
620
|
|
|
{ |
621
|
36 |
|
return $this->options->getComposerName(); |
622
|
|
|
} |
623
|
|
|
/** |
624
|
|
|
* Sets the optionComposerName value |
625
|
|
|
* @param string $optionComposerName |
626
|
|
|
* @return Generator |
627
|
|
|
*/ |
628
|
16 |
|
public function setOptionComposerName($optionComposerName) |
629
|
|
|
{ |
630
|
16 |
|
if (!empty($optionComposerName)) { |
631
|
12 |
|
$this->options->setComposerName($optionComposerName); |
632
|
9 |
|
} else { |
633
|
4 |
|
throw new \InvalidArgumentException('Package\'s composer name can\'t be empty', __LINE__); |
634
|
|
|
} |
635
|
12 |
|
return $this; |
636
|
|
|
} |
637
|
|
|
/** |
638
|
|
|
* Gets the optionStructsFolder value |
639
|
|
|
* @return string |
640
|
|
|
*/ |
641
|
204 |
|
public function getOptionStructsFolder() |
642
|
|
|
{ |
643
|
204 |
|
return $this->options->getStructsFolder(); |
644
|
|
|
} |
645
|
|
|
/** |
646
|
|
|
* Sets the optionStructsFolder value |
647
|
|
|
* @param string $optionStructsFolder |
648
|
|
|
* @return Generator |
649
|
|
|
*/ |
650
|
4 |
|
public function setOptionStructsFolder($optionStructsFolder) |
651
|
|
|
{ |
652
|
4 |
|
$this->options->setStructsFolder($optionStructsFolder); |
653
|
4 |
|
return $this; |
654
|
|
|
} |
655
|
|
|
/** |
656
|
|
|
* Gets the optionArraysFolder value |
657
|
|
|
* @return string |
658
|
|
|
*/ |
659
|
48 |
|
public function getOptionArraysFolder() |
660
|
|
|
{ |
661
|
48 |
|
return $this->options->getArraysFolder(); |
662
|
|
|
} |
663
|
|
|
/** |
664
|
|
|
* Sets the optionArraysFolder value |
665
|
|
|
* @param string $optionArraysFolder |
666
|
|
|
* @return Generator |
667
|
|
|
*/ |
668
|
4 |
|
public function setOptionArraysFolder($optionArraysFolder) |
669
|
|
|
{ |
670
|
4 |
|
$this->options->setArraysFolder($optionArraysFolder); |
671
|
4 |
|
return $this; |
672
|
|
|
} |
673
|
|
|
/** |
674
|
|
|
* Gets the optionEnumsFolder value |
675
|
|
|
* @return string |
676
|
|
|
*/ |
677
|
76 |
|
public function getOptionEnumsFolder() |
678
|
|
|
{ |
679
|
76 |
|
return $this->options->getEnumsFolder(); |
680
|
|
|
} |
681
|
|
|
/** |
682
|
|
|
* Sets the optionEnumsFolder value |
683
|
|
|
* @param string $optionEnumsFolder |
684
|
|
|
* @return Generator |
685
|
|
|
*/ |
686
|
4 |
|
public function setOptionEnumsFolder($optionEnumsFolder) |
687
|
|
|
{ |
688
|
4 |
|
$this->options->setEnumsFolder($optionEnumsFolder); |
689
|
4 |
|
return $this; |
690
|
|
|
} |
691
|
|
|
/** |
692
|
|
|
* Gets the optionServicesFolder value |
693
|
|
|
* @return string |
694
|
|
|
*/ |
695
|
424 |
|
public function getOptionServicesFolder() |
696
|
|
|
{ |
697
|
424 |
|
return $this->options->getServicesFolder(); |
698
|
|
|
} |
699
|
|
|
/** |
700
|
|
|
* Sets the optionServicesFolder value |
701
|
|
|
* @param string $optionServicesFolder |
702
|
|
|
* @return Generator |
703
|
|
|
*/ |
704
|
4 |
|
public function setOptionServicesFolder($optionServicesFolder) |
705
|
|
|
{ |
706
|
4 |
|
$this->options->setServicesFolder($optionServicesFolder); |
707
|
4 |
|
return $this; |
708
|
|
|
} |
709
|
|
|
/** |
710
|
|
|
* Gets the WSDL |
711
|
|
|
* @return Wsdl|null |
712
|
|
|
*/ |
713
|
372 |
|
public function getWsdl() |
714
|
|
|
{ |
715
|
372 |
|
return $this->wsdl; |
716
|
|
|
} |
717
|
|
|
/** |
718
|
|
|
* Sets the WSDLs |
719
|
|
|
* @param Wsdl $wsdl |
720
|
|
|
* @return Generator |
721
|
|
|
*/ |
722
|
408 |
|
protected function setWsdl(Wsdl $wsdl) |
723
|
|
|
{ |
724
|
408 |
|
$this->wsdl = $wsdl; |
725
|
408 |
|
return $this; |
726
|
|
|
} |
727
|
|
|
/** |
728
|
|
|
* Adds Wsdl location |
729
|
|
|
* @param Wsdl $wsdl |
730
|
|
|
* @param string $schemaLocation |
731
|
|
|
* @return Generator |
732
|
|
|
*/ |
733
|
120 |
|
public function addSchemaToWsdl(Wsdl $wsdl, $schemaLocation) |
734
|
|
|
{ |
735
|
120 |
|
if (!empty($schemaLocation) && $wsdl->getContent() instanceof WsdlDocument && $wsdl->getContent()->getExternalSchema($schemaLocation) === null) { |
736
|
112 |
|
$wsdl->getContent()->addExternalSchema(new Schema($wsdl->getGenerator(), $schemaLocation, $this->getUrlContent($schemaLocation))); |
737
|
84 |
|
} |
738
|
120 |
|
return $this; |
739
|
|
|
} |
740
|
|
|
/** |
741
|
|
|
* Gets gather name class |
742
|
|
|
* @param AbstractModel $model the model for which we generate the folder |
743
|
|
|
* @return string |
744
|
|
|
*/ |
745
|
360 |
|
private function getGather(AbstractModel $model) |
746
|
|
|
{ |
747
|
360 |
|
return Utils::getPart($this->getOptionGatherMethods(), $model->getCleanName()); |
748
|
|
|
} |
749
|
|
|
/** |
750
|
|
|
* Returns the service name associated to the method/operation name in order to gather them in one service class |
751
|
|
|
* @uses Generator::getGather() |
752
|
|
|
* @param string $methodName original operation/method name |
753
|
|
|
* @return string |
754
|
|
|
*/ |
755
|
376 |
|
public function getServiceName($methodName) |
756
|
|
|
{ |
757
|
376 |
|
return ucfirst($this->getOptionGatherMethods() === GeneratorOptions::VALUE_NONE ? Service::DEFAULT_SERVICE_CLASS_NAME : $this->getGather(new EmptyModel($this, $methodName))); |
758
|
|
|
} |
759
|
|
|
/** |
760
|
|
|
* @param GeneratorOptions $options |
761
|
|
|
* @return Generator |
762
|
|
|
*/ |
763
|
412 |
|
protected function setOptions(GeneratorOptions $options = null) |
764
|
|
|
{ |
765
|
412 |
|
$this->options = $options; |
766
|
412 |
|
return $this; |
767
|
|
|
} |
768
|
|
|
/** |
769
|
|
|
* @return GeneratorOptions |
770
|
|
|
*/ |
771
|
452 |
|
public function getOptions() |
772
|
|
|
{ |
773
|
452 |
|
return $this->options; |
774
|
|
|
} |
775
|
|
|
/** |
776
|
|
|
* @return GeneratorSoapClient |
777
|
|
|
*/ |
778
|
380 |
|
public function getSoapClient() |
779
|
|
|
{ |
780
|
380 |
|
return $this->soapClient; |
781
|
|
|
} |
782
|
|
|
/** |
783
|
|
|
* @param string $url |
784
|
|
|
* @return string |
785
|
|
|
*/ |
786
|
420 |
|
public function getUrlContent($url) |
787
|
|
|
{ |
788
|
420 |
|
if (strpos($url, '://') !== false) { |
789
|
4 |
|
return Utils::getContentFromUrl($url, $this->getOptionBasicLogin(), $this->getOptionBasicPassword(), $this->getOptionProxyHost(), $this->getOptionProxyPort(), $this->getOptionProxyLogin(), $this->getOptionProxyPassword()); |
790
|
416 |
|
} elseif (is_file($url)) { |
791
|
412 |
|
return file_get_contents($url); |
792
|
|
|
} |
793
|
4 |
|
return null; |
794
|
|
|
} |
795
|
|
|
} |
796
|
|
|
|