Added cache_type option for soap server definition

This commit is contained in:
Francis Besset 2011-09-04 12:59:19 +02:00
parent b1da32bc97
commit 4e33819eca
5 changed files with 48 additions and 5 deletions

View File

@ -106,6 +106,10 @@ class BeSimpleSoapExtension extends Extension
$definition = new DefinitionDecorator('besimple.soap.context.'.$bindingSuffix); $definition = new DefinitionDecorator('besimple.soap.context.'.$bindingSuffix);
$context = $container->setDefinition($contextId, $definition); $context = $container->setDefinition($contextId, $definition);
if (isset($config['cache_type'])) {
$config['cache_type'] = $this->getCacheType($config['cache_type']);
}
$options = $container $options = $container
->getDefinition('besimple.soap.context.'.$bindingSuffix) ->getDefinition('besimple.soap.context.'.$bindingSuffix)
->getArgument(4); ->getArgument(4);

View File

@ -112,6 +112,12 @@ class Configuration
->thenInvalid("Service binding style has to be either 'rpc-literal' or 'document-wrapped'") ->thenInvalid("Service binding style has to be either 'rpc-literal' or 'document-wrapped'")
->end() ->end()
->end() ->end()
->scalarNode('cache_type')
->validate()
->ifNotInArray($this->cacheTypes)
->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes)))
->end()
->end()
->end() ->end()
->end() ->end()
->end() ->end()

View File

@ -28,6 +28,7 @@
<argument type="collection"> <argument type="collection">
<argument key="cache_dir">%besimple.soap.cache_dir%</argument> <argument key="cache_dir">%besimple.soap.cache_dir%</argument>
<argument key="debug">%kernel.debug%</argument> <argument key="debug">%kernel.debug%</argument>
<argument key="cache_type">null</argument>
<argument key="binder_request_header_class">%besimple.soap.binder.request_header.rpcliteral.class%</argument> <argument key="binder_request_header_class">%besimple.soap.binder.request_header.rpcliteral.class%</argument>
<argument key="binder_request_class">%besimple.soap.binder.request.rpcliteral.class%</argument> <argument key="binder_request_class">%besimple.soap.binder.request.rpcliteral.class%</argument>
<argument key="binder_response_class">%besimple.soap.binder.response.rpcliteral.class%</argument> <argument key="binder_response_class">%besimple.soap.binder.response.rpcliteral.class%</argument>
@ -43,6 +44,7 @@
<argument type="collection"> <argument type="collection">
<argument key="cache_dir">%besimple.soap.cache_dir%</argument> <argument key="cache_dir">%besimple.soap.cache_dir%</argument>
<argument key="debug">%kernel.debug%</argument> <argument key="debug">%kernel.debug%</argument>
<argument key="cache_type">null</argument>
<argument key="binder_request_header_class">%besimple.soap.binder.request_header.documentwrapped.class%</argument> <argument key="binder_request_header_class">%besimple.soap.binder.request_header.documentwrapped.class%</argument>
<argument key="binder_request_class">%besimple.soap.binder.request.documentwrapped.class%</argument> <argument key="binder_request_class">%besimple.soap.binder.request.documentwrapped.class%</argument>
<argument key="binder_response_class">%besimple.soap.binder.response.documentwrapped.class%</argument> <argument key="binder_response_class">%besimple.soap.binder.response.documentwrapped.class%</argument>

View File

@ -22,14 +22,42 @@ class SoapServerFactory
private $wsdlFile; private $wsdlFile;
private $classmap; private $classmap;
private $converters; private $converters;
private $debug; private $options;
public function __construct($wsdlFile, array $classmap, ConverterRepository $converters, $debug = false) public function __construct($wsdlFile, array $classmap, ConverterRepository $converters, array $options = array())
{ {
$this->wsdlFile = $wsdlFile; $this->wsdlFile = $wsdlFile;
$this->classmap = $this->fixSoapServerClassmap($classmap); $this->classmap = $this->fixSoapServerClassmap($classmap);
$this->converters = $converters; $this->converters = $converters;
$this->debug = $debug; $this->setOptions($options);
}
public function setOptions(array $options)
{
$this->options = array(
'debug' => false,
'cache_type' => null,
);
// check option names and live merge, if errors are encountered Exception will be thrown
$invalid = array();
$isInvalid = false;
foreach ($options as $key => $value) {
if (array_key_exists($key, $this->options)) {
$this->options[$key] = $value;
} else {
$isInvalid = true;
$invalid[] = $key;
}
}
if ($isInvalid) {
throw new \InvalidArgumentException(sprintf(
'The "%s" class does not support the following options: "%s".',
get_class($this),
implode('\', \'', $invalid)
));
}
} }
public function create($request, $response) public function create($request, $response)
@ -40,7 +68,7 @@ class SoapServerFactory
'classmap' => $this->classmap, 'classmap' => $this->classmap,
'typemap' => $this->createSoapServerTypemap($request, $response), 'typemap' => $this->createSoapServerTypemap($request, $response),
'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
'cache_wsdl' => Cache::getType(), 'cache_wsdl' => null !== $this->options['cache_type'] ? $this->options['cache_type'] : Cache::getType(),
) )
); );
} }

View File

@ -103,7 +103,10 @@ class WebServiceContext
$this->getWsdlFile(), $this->getWsdlFile(),
$this->serviceDefinition->getDefinitionComplexTypes(), $this->serviceDefinition->getDefinitionComplexTypes(),
$this->converterRepository, $this->converterRepository,
$this->options['debug'] array(
'debug' => $this->options['debug'],
'cache_type' => isset($this->options['cache_type']) ? $this->options['cache_type'] : null,
)
); );
} }