Added besimple.soap.classmap service

This commit is contained in:
Francis Besset 2011-10-08 18:03:27 +02:00
parent 94a8a8fec1
commit 1d9bd2cdd3
3 changed files with 27 additions and 0 deletions

View File

@ -96,8 +96,27 @@ class BeSimpleSoapExtension extends Extension
$definition->replaceArgument(1, $defOptions); $definition->replaceArgument(1, $defOptions);
} }
if (!empty($options['classmap'])) {
$classmap = $this->createClientClassmap($client, $options['classmap'], $container);
$definition->replaceArgument(2, new Reference($classmap));
} else {
$definition->replaceArgument(2, null);
} }
} }
}
private function createClientClassmap($client, array $classmap, ContainerBuilder $container)
{
$definition = new DefinitionDecorator('besimple.soap.classmap');
$context = $container->setDefinition(sprintf('besimple.soap.classmap.%s', $client), $definition);
$definition->setMethodCalls(array(
array('set', array($classmap)),
));
return sprintf('besimple.soap.classmap.%s', $client);
}
private function createWebServiceContext(array $config, ContainerBuilder $container) private function createWebServiceContext(array $config, ContainerBuilder $container)
{ {

View File

@ -81,6 +81,10 @@ class Configuration
->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes))) ->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes)))
->end() ->end()
->end() ->end()
->arrayNode('classmap')
->useAttributeAsKey('name')
->prototype('scalar')
->end()
->end() ->end()
->end() ->end()
->end() ->end()

View File

@ -5,6 +5,7 @@
<parameters> <parameters>
<parameter key="besimple.soap.client.class">BeSimple\SoapClient\SoapClient</parameter> <parameter key="besimple.soap.client.class">BeSimple\SoapClient\SoapClient</parameter>
<parameter key="besimple.soap.classmap.class">BeSimple\SoapCommon\Classmap</parameter>
</parameters> </parameters>
<services> <services>
@ -15,9 +16,12 @@
<argument key="cache_type">null</argument> <argument key="cache_type">null</argument>
<argument key="namespace">null</argument> <argument key="namespace">null</argument>
</argument> </argument>
<argument type="service" id="besimple.soap.classmap" />
<argument type="service" id="besimple.soap.converter.collection" /> <argument type="service" id="besimple.soap.converter.collection" />
<argument type="service" id="besimple.soap.cache" /> <argument type="service" id="besimple.soap.cache" />
</service> </service>
<service id="besimple.soap.classmap" class="%besimple.soap.classmap.class%" abstract="true" />
</services> </services>
</container> </container>