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