diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php
index 5abd6de..f44f2a5 100644
--- a/DependencyInjection/BeSimpleSoapExtension.php
+++ b/DependencyInjection/BeSimpleSoapExtension.php
@@ -67,23 +67,7 @@ class BeSimpleSoapExtension extends Extension
{
$loader->load('soap.xml');
- switch ($config['type']) {
- case 'none':
- $config['type'] = Cache::TYPE_NONE;
- break;
-
- case 'disk':
- $config['type'] = Cache::TYPE_DISK;
- break;
-
- case 'memory':
- $config['type'] = Cache::TYPE_MEMORY;
- break;
-
- case 'disk_memory':
- $config['type'] = Cache::TYPE_DISK_MEMORY;
- break;
- }
+ $config['type'] = $this->getCacheType($config['type']);
foreach (array('type', 'lifetime', 'limit') as $key) {
$container->setParameter('besimple.soap.cache.'.$key, $config[$key]);
@@ -99,6 +83,17 @@ class BeSimpleSoapExtension extends Extension
$context = $container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition);
$definition->replaceArgument(0, $options['wsdl']);
+
+ if (isset($options['cache_wsdl'])) {
+ $options['cache_wsdl'] = $this->getCacheType($options['cache_wsdl']);
+
+ $defOptions = $container
+ ->getDefinition('besimple.soap.client')
+ ->getArgument(1);
+
+ $defOptions['cache_wsdl'] = $options['cache_wsdl'];
+ $definition->replaceArgument(1, $defOptions);
+ }
}
}
@@ -117,4 +112,21 @@ class BeSimpleSoapExtension extends Extension
$definition->replaceArgument(4, array_merge($options, $config));
}
+
+ private function getCacheType($type)
+ {
+ switch ($type) {
+ case 'none':
+ return Cache::TYPE_NONE;
+
+ case 'disk':
+ return Cache::TYPE_DISK;
+
+ case 'memory':
+ return Cache::TYPE_MEMORY;
+
+ case 'disk_memory':
+ return Cache::TYPE_DISK_MEMORY;
+ }
+ }
}
diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index dde299d..f856ee8 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -23,6 +23,8 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder;
*/
class Configuration
{
+ private $cacheTypes = array('none', 'disk', 'memory', 'disk_memory');
+
/**
* Generates the configuration tree.
*
@@ -46,12 +48,13 @@ class Configuration
$rootNode
->children()
->arrayNode('cache')
+ ->addDefaultsIfNotSet()
->children()
->scalarNode('type')
->defaultValue('disk')
->validate()
- ->ifNotInArray(array('none', 'disk', 'memory', 'disk_memory'))
- ->thenInvalid('The cache type has to be either "none", "disk", "memory" or "disk_memory"')
+ ->ifNotInArray($this->cacheTypes)
+ ->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes)))
->end()
->end()
->scalarNode('lifetime')->defaultNull()->end()
@@ -73,6 +76,12 @@ class Configuration
->scalarNode('wsdl')
->isRequired()
->end()
+ ->scalarNode('cache_wsdl')
+ ->validate()
+ ->ifNotInArray($this->cacheTypes)
+ ->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes)))
+ ->end()
+ ->end()
->end()
->end()
->end()
diff --git a/Resources/config/client.xml b/Resources/config/client.xml
index 7869c80..72acfef 100644
--- a/Resources/config/client.xml
+++ b/Resources/config/client.xml
@@ -12,6 +12,7 @@
wsdl
%kernel.debug%
+ null