1
|
|
|
<?php |
2
|
|
|
namespace GoetasWebservices\SoapServices\SoapClient\Command; |
3
|
|
|
|
4
|
|
|
use GoetasWebservices\SoapServices\SoapClient\Builder\SoapContainerBuilder; |
5
|
|
|
use Symfony\Component\Console\Command\Command; |
6
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Input\InputOption; |
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
10
|
|
|
use Zend\Code\Generator\FileGenerator; |
11
|
|
|
|
12
|
|
|
class Generate extends Command |
13
|
|
|
{ |
14
|
|
|
protected function configure() |
15
|
|
|
{ |
16
|
|
|
parent::configure(); |
17
|
|
|
$this->setName('generate'); |
18
|
|
|
$this->setDescription("Convert create all the necessary PHP classes for a SOAP client"); |
19
|
|
|
$this->setDefinition([ |
20
|
|
|
new InputArgument('config', InputArgument::REQUIRED, 'Config file location'), |
21
|
|
|
new InputArgument('dest-dir', InputArgument::REQUIRED, 'Config file location'), |
22
|
|
|
new InputOption('dest-class', null, InputOption::VALUE_REQUIRED, 'Config file location'), |
23
|
|
|
]); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param InputInterface $input |
28
|
|
|
* @param OutputInterface $output |
29
|
|
|
* @return int |
30
|
|
|
*/ |
31
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
32
|
|
|
{ |
33
|
|
|
$containerBuilder = new SoapContainerBuilder($input->getArgument('config')); |
34
|
|
|
|
35
|
|
|
if ($input->getOption('dest-class')) { |
36
|
|
|
$containerBuilder->setContainerClassName($input->getOption('dest-class')); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
$debugContainer = $containerBuilder->getDebugContainer(); |
40
|
|
|
|
41
|
|
|
$wsdlMetadata = $debugContainer->getParameter('wsdl2php.config')['metadata']; |
42
|
|
|
|
43
|
|
|
$schemas = []; |
44
|
|
|
$portTypes = []; |
45
|
|
|
$wsdlReader = $debugContainer->get('goetas.wsdl2php.wsdl_reader'); |
46
|
|
|
|
47
|
|
|
foreach (array_keys($wsdlMetadata) as $src) { |
48
|
|
|
$definitions = $wsdlReader->readFile($src); |
49
|
|
|
$schemas[] = $definitions->getSchema(); |
50
|
|
|
$portTypes = array_merge($portTypes, $definitions->getPortTypes()); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$soapReader = $debugContainer->get('goetas.wsdl2php.soap_reader'); |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
foreach (['php', 'jms'] as $type) { |
57
|
|
|
$converter = $debugContainer->get('goetas.xsd2php.converter.' . $type); |
58
|
|
|
$wsdlConverter = $debugContainer->get('goetas.wsdl2php.converter.' . $type); |
59
|
|
|
$items = $wsdlConverter->visitServices($soapReader->getServices()); |
60
|
|
|
$items = array_merge($items, $converter->convert($schemas)); |
61
|
|
|
|
62
|
|
|
$writer = $debugContainer->get('goetas.xsd2php.writer.' . $type); |
63
|
|
|
$writer->write($items); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @var $clientStubGenerator \GoetasWebservices\SoapServices\SoapClient\StubGeneration\ClientStubGenerator |
68
|
|
|
*/ |
69
|
|
|
$clientStubGenerator = $debugContainer->get('goetas.wsdl2php.stub.client_generator'); |
70
|
|
|
|
71
|
|
|
$classDefinitions = $clientStubGenerator->generate($portTypes); |
72
|
|
|
$classWriter = $debugContainer->get('goetas.xsd2php.class_writer.php'); |
73
|
|
|
$classWriter->write($classDefinitions); |
74
|
|
|
|
75
|
|
|
$containerDumped = $containerBuilder->dumpContainerForProd($input->getArgument('dest-dir'), $debugContainer); |
|
|
|
|
76
|
|
|
|
77
|
|
|
return $containerDumped ? 0 : 255; |
78
|
|
|
|
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.