|
1
|
|
|
<?php |
|
2
|
|
|
namespace GoetasWebservices\SoapServices\SoapCommon\Command; |
|
3
|
|
|
|
|
4
|
|
|
use Symfony\Component\Console\Command\Command; |
|
5
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
6
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
9
|
|
|
|
|
10
|
|
|
abstract class Generate extends Command |
|
11
|
|
|
{ |
|
12
|
|
|
private $debugContainer; |
|
13
|
|
|
|
|
14
|
|
|
protected function configure() |
|
15
|
|
|
{ |
|
16
|
|
|
parent::configure(); |
|
17
|
|
|
$this->setName('generate'); |
|
18
|
|
|
$this->setDefinition([ |
|
19
|
|
|
new InputArgument('config', InputArgument::REQUIRED, 'Config file location'), |
|
20
|
|
|
new InputArgument('dest-dir', InputArgument::REQUIRED, 'Config file location'), |
|
21
|
|
|
new InputOption('dest-class', null, InputOption::VALUE_REQUIRED, 'Config file location'), |
|
22
|
|
|
]); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @return \GoetasWebservices\SoapServices\SoapCommon\Builder\SoapContainerBuilder |
|
27
|
|
|
*/ |
|
28
|
|
|
protected abstract function getContainerBuilder(); |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param InputInterface $input |
|
32
|
|
|
* @param OutputInterface $output |
|
33
|
|
|
* @return int |
|
34
|
|
|
*/ |
|
35
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
36
|
|
|
{ |
|
37
|
|
|
$containerBuilder = $this->getContainerBuilder(); |
|
38
|
|
|
|
|
39
|
|
|
$containerBuilder->setConfigFile($input->getArgument('config')); |
|
40
|
|
|
|
|
41
|
|
|
if ($input->getOption('dest-class')) { |
|
42
|
|
|
$containerBuilder->setContainerClassName($input->getOption('dest-class')); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
$this->debugContainer = $containerBuilder->getDebugContainer(); |
|
46
|
|
|
|
|
47
|
|
|
$wsdlMetadata = $this->debugContainer->getParameter('wsdl2php.config')['metadata']; |
|
48
|
|
|
|
|
49
|
|
|
$schemas = []; |
|
50
|
|
|
$portTypes = []; |
|
51
|
|
|
$wsdlReader = $this->debugContainer->get('goetas_webservices.wsdl2php.wsdl_reader'); |
|
52
|
|
|
|
|
53
|
|
|
foreach (array_keys($wsdlMetadata) as $src) { |
|
54
|
|
|
$definitions = $wsdlReader->readFile($src); |
|
55
|
|
|
$schemas[] = $definitions->getSchema(); |
|
56
|
|
|
$portTypes = array_merge($portTypes, $definitions->getPortTypes()); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
$soapReader = $this->debugContainer->get('goetas_webservices.wsdl2php.soap_reader'); |
|
60
|
|
|
|
|
61
|
|
|
foreach (['php', 'jms'] as $type) { |
|
62
|
|
|
$converter = $this->debugContainer->get('goetas_webservices.xsd2php.converter.' . $type); |
|
63
|
|
|
$wsdlConverter = $this->debugContainer->get('goetas_webservices.wsdl2php.converter.' . $type); |
|
64
|
|
|
$items = $wsdlConverter->visitServices($soapReader->getServices()); |
|
65
|
|
|
$items = array_merge($items, $converter->convert($schemas)); |
|
66
|
|
|
|
|
67
|
|
|
$writer = $this->debugContainer->get('goetas_webservices.xsd2php.writer.' . $type); |
|
68
|
|
|
$writer->write($items); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|