diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php index a2840ba..02bb008 100644 --- a/DependencyInjection/BeSimpleSoapExtension.php +++ b/DependencyInjection/BeSimpleSoapExtension.php @@ -96,9 +96,28 @@ class BeSimpleSoapExtension extends Extension $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) { $bindingSuffix = $this->bindingConfigToServiceSuffixMap[$config['binding']]; diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 3b15368..bb8bedf 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -81,6 +81,10 @@ class Configuration ->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes))) ->end() ->end() + ->arrayNode('classmap') + ->useAttributeAsKey('name') + ->prototype('scalar') + ->end() ->end() ->end() ->end() diff --git a/Resources/config/client.xml b/Resources/config/client.xml index 102f34b..efc63ca 100644 --- a/Resources/config/client.xml +++ b/Resources/config/client.xml @@ -5,6 +5,7 @@ BeSimple\SoapClient\SoapClient + BeSimple\SoapCommon\Classmap @@ -15,9 +16,12 @@ null null + + +