2010-10-04 20:27:00 +02:00
|
|
|
<?php
|
2010-10-05 21:44:30 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the WebServiceBundle.
|
|
|
|
*
|
|
|
|
* (c) Christian Kerl <christian-kerl@web.de>
|
|
|
|
*
|
|
|
|
* This source file is subject to the MIT license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
2010-10-04 20:27:00 +02:00
|
|
|
|
|
|
|
namespace Bundle\WebServiceBundle\DependencyInjection;
|
|
|
|
|
2011-02-03 01:04:12 +01:00
|
|
|
use Bundle\WebServiceBundle\Util\Assert;
|
|
|
|
|
2010-10-04 20:27:00 +02:00
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
2010-10-05 21:44:30 +02:00
|
|
|
use Symfony\Component\DependencyInjection\Extension\Extension;
|
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
2010-10-04 20:27:00 +02:00
|
|
|
|
2010-10-05 21:44:30 +02:00
|
|
|
/**
|
|
|
|
* WebServiceExtension.
|
|
|
|
*
|
|
|
|
* @author Christian Kerl <christian-kerl@web.de>
|
|
|
|
*/
|
2010-10-04 20:27:00 +02:00
|
|
|
class WebServiceExtension extends Extension
|
|
|
|
{
|
2010-10-04 20:39:04 +02:00
|
|
|
public function configLoad(array $config, ContainerBuilder $configuration)
|
|
|
|
{
|
2010-12-30 02:18:10 +01:00
|
|
|
if(!$configuration->hasDefinition('webservice.kernel'))
|
2010-10-05 21:44:30 +02:00
|
|
|
{
|
2010-10-06 00:00:15 +02:00
|
|
|
$loader = new XmlFileLoader($configuration, __DIR__ . '/../Resources/config');
|
|
|
|
$loader->load('services.xml');
|
2010-10-04 21:13:45 +02:00
|
|
|
|
2010-10-07 15:16:56 +02:00
|
|
|
$configuration->setAlias('http_kernel', 'webservice.kernel');
|
2010-10-05 21:44:30 +02:00
|
|
|
}
|
2010-10-06 00:00:15 +02:00
|
|
|
|
2010-10-08 14:24:42 +02:00
|
|
|
if(isset($config['definition']))
|
|
|
|
{
|
|
|
|
$this->registerServiceDefinitionConfig($config['definition'], $configuration);
|
|
|
|
}
|
|
|
|
else
|
2010-10-07 15:16:56 +02:00
|
|
|
{
|
|
|
|
throw new \InvalidArgumentException();
|
|
|
|
}
|
|
|
|
|
2010-10-08 14:24:42 +02:00
|
|
|
if(isset($config['binding']))
|
|
|
|
{
|
|
|
|
$this->registerServiceBindingConfig($config['binding'], $configuration);
|
|
|
|
}
|
2010-10-07 15:16:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function registerServiceDefinitionConfig(array $config, ContainerBuilder $configuration)
|
|
|
|
{
|
2011-02-03 01:04:12 +01:00
|
|
|
Assert::thatArgument('config.name', isset($config['name']));
|
|
|
|
Assert::thatArgument('config.namespace', isset($config['namespace']));
|
2010-10-07 15:16:56 +02:00
|
|
|
|
|
|
|
$configuration->setParameter('webservice.definition.name', $config['name']);
|
2011-02-03 01:04:12 +01:00
|
|
|
$configuration->setParameter('webservice.definition.namespace', $config['namespace']);
|
2010-10-07 15:16:56 +02:00
|
|
|
$configuration->setParameter('webservice.definition.resource', isset($config['resource']) ? $config['resource'] : null);
|
2010-12-30 02:18:10 +01:00
|
|
|
$configuration->setParameter('webservice.definition.wsdl', isset($config['wsdl']) ? $config['wsdl'] : null);
|
2010-10-04 20:39:04 +02:00
|
|
|
}
|
2010-10-04 20:27:00 +02:00
|
|
|
|
2010-10-08 14:24:42 +02:00
|
|
|
protected function registerServiceBindingConfig(array $config, ContainerBuilder $configuration)
|
|
|
|
{
|
|
|
|
$style = isset($config['style']) ? $config['style'] : 'document-literal-wrapped';
|
|
|
|
|
|
|
|
if(!in_array($style, array('document-literal-wrapped', 'rpc-literal')))
|
|
|
|
{
|
|
|
|
throw new \InvalidArgumentException();
|
|
|
|
}
|
|
|
|
|
|
|
|
$binderNamespace = 'Bundle\\WebServiceBundle\\ServiceBinding\\';
|
|
|
|
|
|
|
|
switch ($style)
|
|
|
|
{
|
|
|
|
case 'document-literal-wrapped':
|
|
|
|
$configuration->setParameter('webservice.binder.request.class', $binderNamespace . 'DocumentLiteralWrappedRequestMessageBinder');
|
|
|
|
$configuration->setParameter('webservice.binder.response.class', $binderNamespace . 'DocumentLiteralWrappedResponseMessageBinder');
|
|
|
|
break;
|
|
|
|
case 'rpc-literal':
|
|
|
|
$configuration->setParameter('webservice.binder.request.class', $binderNamespace . 'RpcLiteralRequestMessageBinder');
|
|
|
|
$configuration->setParameter('webservice.binder.response.class', $binderNamespace . 'RpcLiteralResponseMessageBinder');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-04 20:27:00 +02:00
|
|
|
public function getXsdValidationBasePath()
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getNamespace()
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAlias()
|
|
|
|
{
|
|
|
|
return 'webservice';
|
|
|
|
}
|
|
|
|
}
|