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