Simplified the creation of WebServiceContext
This commit is contained in:
parent
c33005fed2
commit
9bd9677325
|
@ -25,10 +25,11 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
|||
*/
|
||||
class BeSimpleSoapExtension extends Extension
|
||||
{
|
||||
private $contextArguments;
|
||||
|
||||
// maps config options to service suffix
|
||||
private $bindingConfigToServiceSuffixMap = array('rpc-literal' => '.rpcliteral', 'document-wrapped' => '.documentwrapped');
|
||||
private $bindingConfigToServiceSuffixMap = array(
|
||||
'rpc-literal' => 'rpcliteral',
|
||||
'document-wrapped' => 'documentwrapped'
|
||||
);
|
||||
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
|
@ -53,27 +54,14 @@ class BeSimpleSoapExtension extends Extension
|
|||
$bindingSuffix = $this->bindingConfigToServiceSuffixMap[$config['binding']];
|
||||
unset($config['binding']);
|
||||
|
||||
if (null === $this->contextArguments) {
|
||||
$this->contextArguments = $container
|
||||
->getDefinition('besimple.soap.context')
|
||||
->getArguments()
|
||||
;
|
||||
}
|
||||
|
||||
$contextId = 'besimple.soap.context.'.$config['name'];
|
||||
$context = $container->setDefinition($contextId, $definition = new DefinitionDecorator('besimple.soap.context'));
|
||||
$definition = new DefinitionDecorator('besimple.soap.context.'.$bindingSuffix);
|
||||
$context = $container->setDefinition($contextId, $definition);
|
||||
|
||||
$arguments = array();
|
||||
foreach($this->contextArguments as $i => $argument) {
|
||||
if (in_array($i, array(1, 2, 3))) {
|
||||
$argument = new Reference($argument->__toString().$bindingSuffix);
|
||||
} elseif (6 === $i) {
|
||||
$argument = array_merge($argument, $config);
|
||||
} else {
|
||||
$argument = new Reference($argument->__toString());
|
||||
}
|
||||
$options = $container
|
||||
->getDefinition('besimple.soap.context.'.$bindingSuffix)
|
||||
->getArgument(6);
|
||||
|
||||
$definition->replaceArgument($i, $argument);
|
||||
}
|
||||
$definition->replaceArgument(6, array_merge($options, $config));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,24 @@
|
|||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="besimple.soap.context" class="%besimple.soap.context.class%" abstract="true">
|
||||
<service id="besimple.soap.context.rpcliteral" class="%besimple.soap.context.class%" abstract="true">
|
||||
<argument type="service" id="besimple.soap.definition.loader" />
|
||||
<argument type="service" id="besimple.soap.definition.dumper.wsdl"/>
|
||||
<argument type="service" id="besimple.soap.binder.request"/>
|
||||
<argument type="service" id="besimple.soap.binder.response"/>
|
||||
<argument type="service" id="besimple.soap.definition.dumper.wsdl.rpcliteral" />
|
||||
<argument type="service" id="besimple.soap.binder.request.rpcliteral" />
|
||||
<argument type="service" id="besimple.soap.binder.response.rpcliteral" />
|
||||
<argument type="service" id="besimple.soap.type.repository" />
|
||||
<argument type="service" id="besimple.soap.converter.repository" />
|
||||
<argument type="collection">
|
||||
<argument key="cache_dir">%besimple.soap.cache_dir%</argument>
|
||||
<argument key="debug">%kernel.debug%</argument>
|
||||
</argument>
|
||||
</service>
|
||||
|
||||
<service id="besimple.soap.context.documentwrapped" class="%besimple.soap.context.class%" abstract="true">
|
||||
<argument type="service" id="besimple.soap.definition.loader" />
|
||||
<argument type="service" id="besimple.soap.definition.dumper.wsdl.rpcliteral" />
|
||||
<argument type="service" id="besimple.soap.binder.request.documentwrapped" />
|
||||
<argument type="service" id="besimple.soap.binder.response.documentwrapped" />
|
||||
<argument type="service" id="besimple.soap.type.repository" />
|
||||
<argument type="service" id="besimple.soap.converter.repository" />
|
||||
<argument type="collection">
|
||||
|
|
Loading…
Reference in New Issue