diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php index 5870366..9b492b7 100644 --- a/DependencyInjection/BeSimpleSoapExtension.php +++ b/DependencyInjection/BeSimpleSoapExtension.php @@ -44,6 +44,10 @@ class BeSimpleSoapExtension extends Extension $config = $processor->process($configuration->getConfigTree(), $configs); + if (isset($config['clients'])) { + $this->registerClientConfiguration($config['clients'], $container, $loader); + } + $container->setParameter('besimple.soap.definition.dumper.options.stylesheet', $config['wsdl_dumper']['stylesheet']); foreach($config['services'] as $name => $serviceConfig) { @@ -52,6 +56,18 @@ class BeSimpleSoapExtension extends Extension } } + private function registerClientConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) + { + $loader->load('client.xml'); + + foreach ($config as $client => $options) { + $definition = new DefinitionDecorator('besimple.soap.client'); + $context = $container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition); + + $definition->replaceArgument(0, $options['wsdl']); + } + } + private function createWebServiceContext(array $config, ContainerBuilder $container) { $bindingSuffix = $this->bindingConfigToServiceSuffixMap[$config['binding']]; diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 0f538cc..2228f37 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -30,12 +30,30 @@ class Configuration $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('be_simple_soap'); + $this->addClientSection($rootNode); $this->addServicesSection($rootNode); $this->addWsdlDumperSection($rootNode); return $treeBuilder->buildTree(); } + private function addClientSection(ArrayNodeDefinition $rootNode) + { + $rootNode + ->children() + ->arrayNode('clients') + ->useAttributeAsKey('name') + ->prototype('array') + ->children() + ->scalarNode('wsdl') + ->isRequired() + ->end() + ->end() + ->end() + ->end() + ; + } + private function addServicesSection(ArrayNodeDefinition $rootNode) { $rootNode diff --git a/Resources/config/client.xml b/Resources/config/client.xml new file mode 100644 index 0000000..1fc90f1 --- /dev/null +++ b/Resources/config/client.xml @@ -0,0 +1,19 @@ + + + + + BeSimple\SoapClient\Soap\SoapClient + + + + + wsdl + + %kernel.debug% + + + + +