|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the AMFWebServicesClientBundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Amine Fattouch <http://github.com/fattouchsquall> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace AMF\WebServicesClientBundle\DependencyInjection\Compiler; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
15
|
|
|
use Symfony\Component\DependencyInjection\DefinitionDecorator; |
|
16
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
17
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
18
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Pass of compilation to register Soap webservices. |
|
22
|
|
|
* |
|
23
|
|
|
* @author Mohamed Amine Fattouch <[email protected]> |
|
24
|
|
|
*/ |
|
25
|
|
|
class RegisterSoapWebServicesPass implements CompilerPassInterface |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* Register soap webservices definition. |
|
29
|
|
|
* |
|
30
|
|
|
* @param ContainerBuilder $container Instance of container. |
|
31
|
|
|
*/ |
|
32
|
|
|
public function process(ContainerBuilder $container) |
|
33
|
|
|
{ |
|
34
|
|
|
if ($container->hasParameter('amf_web_services_client.soap.endpoints') === false) { |
|
35
|
|
|
return; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
$endpoints = $container->getParameter('amf_web_services_client.soap.endpoints'); |
|
39
|
|
|
foreach ($endpoints as $key => $endpoint) { |
|
40
|
|
|
$soapClient = $container->getDefinition('amf_web_services_client.soap') |
|
41
|
|
|
->replaceArgument(0, $endpoint['wsdl']) |
|
42
|
|
|
->replaceArgument(0, $endpoint['options']); |
|
43
|
|
|
|
|
44
|
|
|
$soapEndpoint = 'amf_web_services_client.soap.'.$key; |
|
45
|
|
|
$container->setDefinition( |
|
46
|
|
|
$soapEndpoint, |
|
47
|
|
|
new DefinitionDecorator('amf_web_services_client.soap.endpoint') |
|
48
|
|
|
) |
|
49
|
|
|
->setClass($endpoint['class']) |
|
50
|
|
|
->replaceArgument(0, $soapClient) |
|
51
|
|
|
->replaceArgument(1, $this->addWsseDefinition($container, $key, $wsse)) |
|
|
|
|
|
|
52
|
|
|
->replaceArgument(3, $endpoint['wsse']['enabled']); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Adds wsse defintion to container only if it's enabled.. |
|
58
|
|
|
* |
|
59
|
|
|
* @param ContainerInterface $container |
|
60
|
|
|
* @param string $key |
|
61
|
|
|
* @param array $wsse |
|
62
|
|
|
* |
|
63
|
|
|
* @return Reference|null |
|
64
|
|
|
*/ |
|
65
|
|
View Code Duplication |
private function addWsseDefinition(ContainerInterface $container, $key, array $wsse) |
|
|
|
|
|
|
66
|
|
|
{ |
|
67
|
|
|
if (($wsse['enabled'] === true)) { |
|
68
|
|
|
$soapWsse = 'amf_web_services_client.soap.wsse.'.$key; |
|
69
|
|
|
$container |
|
|
|
|
|
|
70
|
|
|
->setDefinition($soapWsse, new DefinitionDecorator('amf_web_services_client.soap.wsse')) |
|
71
|
|
|
->replaceArgument(0, $wsse['wsse']['username']) |
|
72
|
|
|
->replaceArgument(1, $wsse['wsse']['password']); |
|
73
|
|
|
|
|
74
|
|
|
return new Reference($soapWsse); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
return null; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.