1
|
|
|
<?php |
2
|
|
|
namespace GoetasWebservices\SoapServices\SoapClient\DependencyInjection\Compiler; |
3
|
|
|
|
4
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
5
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
6
|
|
|
|
7
|
|
|
class ConfigurePass implements CompilerPassInterface |
8
|
|
|
{ |
9
|
|
|
|
10
|
|
|
public function process(ContainerBuilder $container) |
11
|
|
|
{ |
12
|
|
|
$soapConfig = $container->getParameter('goetas.soap_client.config'); |
13
|
|
|
$xsd2phpConfig = $container->getParameter('xsd2php.config'); |
14
|
|
|
$wsdlConfig = $container->getParameter('wsdl2php.config'); |
15
|
|
|
$metadataGenerator = $container->getDefinition('goetas.wsdl2php.metadata.generator'); |
16
|
|
|
foreach ($soapConfig['alternative_endpoints'] as $service => $data) { |
17
|
|
|
foreach ($data as $port => $endPoint) { |
18
|
|
|
$metadataGenerator->addMethodCall('addAlternativeEndpoint', [$service, $port, $endPoint]); |
19
|
|
|
} |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
$writer = $container->getDefinition('goetas.wsdl2php.metadata.generator'); |
23
|
|
|
$keys = ['headers', 'parts', 'messages']; |
24
|
|
|
$writer->addMethodCall('setBaseNs', [array_intersect_key($wsdlConfig, array_combine($keys, $keys))]); |
25
|
|
|
$writer->addMethodCall('setUnwrap', [$soapConfig['unwrap_returns']]); |
26
|
|
|
$writer->replaceArgument(1, $xsd2phpConfig['namespaces']); |
27
|
|
|
|
28
|
|
|
$writer = $container->getDefinition('goetas.wsdl2php.stub.client_generator'); |
29
|
|
|
$writer->addMethodCall('setUnwrap', [$soapConfig['unwrap_returns']]); |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
$forProduction = !!$container->getParameter('goetas.soap_client.metadata'); |
33
|
|
|
|
34
|
|
|
$readerName = 'goetas.wsdl2php.metadata_loader.' . ($forProduction ? 'array' : 'dev'); |
35
|
|
|
$reader = clone $container->getDefinition($readerName); |
36
|
|
|
$container->setDefinition('goetas.soap_client.metadata_reader', $reader); |
37
|
|
|
} |
38
|
|
|
} |
39
|
|
|
|