Added the possibility to choice an other type cache for a client
This commit is contained in:
parent
1a4e9246db
commit
2ea1704a1e
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<argument>wsdl</argument>
|
||||
<argument type="collection">
|
||||
<argument key="debug">%kernel.debug%</argument>
|
||||
<argument key="cache_wsdl">null</argument>
|
||||
</argument>
|
||||
<argument type="service" id="besimple.soap.cache" />
|
||||
</service>
|
||||
|
|
Loading…
Reference in New Issue