Refactored the declaration of services for ServiceBinder

This commit is contained in:
Francis Besset 2011-08-14 21:06:04 +02:00
parent d3a8965500
commit 33165ce8d2
3 changed files with 12 additions and 21 deletions

View File

@ -60,8 +60,8 @@ class BeSimpleSoapExtension extends Extension
$options = $container
->getDefinition('besimple.soap.context.'.$bindingSuffix)
->getArgument(6);
->getArgument(4);
$definition->replaceArgument(6, array_merge($options, $config));
$definition->replaceArgument(4, array_merge($options, $config));
}
}

View File

@ -19,37 +19,29 @@
<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.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 key="binder_request_class">%besimple.soap.binder.request.rpcliteral.class%</argument>
<argument key="binder_response_class">%besimple.soap.binder.response.rpcliteral.class%</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.documentwrapped" />
<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">
<argument key="cache_dir">%besimple.soap.cache_dir%</argument>
<argument key="debug">%kernel.debug%</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>
</service>
<service id="besimple.soap.binder.request.rpcliteral" class="%besimple.soap.binder.request.rpcliteral.class%" />
<service id="besimple.soap.binder.response.rpcliteral" class="%besimple.soap.binder.response.rpcliteral.class%" />
<service id="besimple.soap.binder.request.documentwrapped" class="%besimple.soap.binder.request.documentwrapped.class%" />
<service id="besimple.soap.binder.response.documentwrapped" class="%besimple.soap.binder.response.documentwrapped.class%" />
<service id="besimple.soap.definition.dumper.wsdl.rpcliteral" class="%besimple.soap.definition.dumper.wsdl.rpcliteral.class%">
<argument type="service" id="besimple.soap.definition.loader.annot_complextype" />
</service>

View File

@ -27,8 +27,6 @@ use Symfony\Component\Config\Loader\LoaderInterface;
*/
class WebServiceContext
{
private $requestMessageBinder;
private $responseMessageBinder;
private $typeRepository;
private $converterRepository;
@ -40,13 +38,10 @@ class WebServiceContext
private $serviceBinder;
private $serverFactory;
public function __construct(LoaderInterface $loader, DumperInterface $dumper, MessageBinderInterface $requestMessageBinder, MessageBinderInterface $responseMessageBinder, TypeRepository $typeRepository, ConverterRepository $converterRepository, array $options) {
public function __construct(LoaderInterface $loader, DumperInterface $dumper, TypeRepository $typeRepository, ConverterRepository $converterRepository, array $options) {
$this->loader = $loader;
$this->wsdlFileDumper = $dumper;
$this->requestMessageBinder = $requestMessageBinder;
$this->responseMessageBinder = $responseMessageBinder;
$this->typeRepository = $typeRepository;
$this->converterRepository = $converterRepository;
@ -90,7 +85,11 @@ class WebServiceContext
public function getServiceBinder()
{
if (null === $this->serviceBinder) {
$this->serviceBinder = new ServiceBinder($this->getServiceDefinition(), $this->requestMessageBinder, $this->responseMessageBinder);
$this->serviceBinder = new ServiceBinder(
$this->getServiceDefinition(),
new $this->options['binder_request_class'](),
new $this->options['binder_response_class']()
);
}
return $this->serviceBinder;