2011-03-26 16:43:41 +01:00
|
|
|
<?php
|
2011-09-04 01:59:32 +02:00
|
|
|
|
2011-03-26 16:43:41 +01:00
|
|
|
/*
|
2011-07-18 22:43:12 +02:00
|
|
|
* This file is part of the BeSimpleSoapBundle.
|
2011-03-26 16:43:41 +01:00
|
|
|
*
|
|
|
|
* (c) Christian Kerl <christian-kerl@web.de>
|
2011-09-04 01:59:32 +02:00
|
|
|
* (c) Francis Besset <francis.besset@gmail.com>
|
2011-03-26 16:43:41 +01:00
|
|
|
*
|
|
|
|
* This source file is subject to the MIT license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
|
|
|
|
2011-07-18 22:43:12 +02:00
|
|
|
namespace BeSimple\SoapBundle\DependencyInjection;
|
2011-03-26 16:43:41 +01:00
|
|
|
|
2011-08-14 21:59:03 +02:00
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
2011-03-26 16:43:41 +01:00
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WebServiceExtension configuration structure.
|
|
|
|
*
|
|
|
|
* @author Christian Kerl <christian-kerl@web.de>
|
2011-09-04 01:59:32 +02:00
|
|
|
* @author Francis Besset <francis.besset@gmail.com>
|
2011-03-26 16:43:41 +01:00
|
|
|
*/
|
|
|
|
class Configuration
|
|
|
|
{
|
2011-09-04 02:42:53 +02:00
|
|
|
private $cacheTypes = array('none', 'disk', 'memory', 'disk_memory');
|
|
|
|
|
2011-03-26 16:43:41 +01:00
|
|
|
/**
|
|
|
|
* Generates the configuration tree.
|
|
|
|
*
|
|
|
|
* @return \Symfony\Component\Config\Definition\ArrayNode The config tree
|
|
|
|
*/
|
|
|
|
public function getConfigTree()
|
|
|
|
{
|
|
|
|
$treeBuilder = new TreeBuilder();
|
2011-08-14 21:59:03 +02:00
|
|
|
$rootNode = $treeBuilder->root('be_simple_soap');
|
2011-03-26 16:43:41 +01:00
|
|
|
|
2011-09-04 01:59:32 +02:00
|
|
|
$this->addCacheSection($rootNode);
|
2011-09-03 21:17:57 +02:00
|
|
|
$this->addClientSection($rootNode);
|
2011-08-14 21:59:03 +02:00
|
|
|
$this->addServicesSection($rootNode);
|
|
|
|
$this->addWsdlDumperSection($rootNode);
|
|
|
|
|
|
|
|
return $treeBuilder->buildTree();
|
|
|
|
}
|
|
|
|
|
2011-09-04 01:59:32 +02:00
|
|
|
private function addCacheSection(ArrayNodeDefinition $rootNode)
|
|
|
|
{
|
|
|
|
$rootNode
|
|
|
|
->children()
|
|
|
|
->arrayNode('cache')
|
2011-09-04 02:42:53 +02:00
|
|
|
->addDefaultsIfNotSet()
|
2011-09-04 01:59:32 +02:00
|
|
|
->children()
|
|
|
|
->scalarNode('type')
|
|
|
|
->defaultValue('disk')
|
|
|
|
->validate()
|
2011-09-04 02:42:53 +02:00
|
|
|
->ifNotInArray($this->cacheTypes)
|
|
|
|
->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes)))
|
2011-09-04 01:59:32 +02:00
|
|
|
->end()
|
|
|
|
->end()
|
|
|
|
->scalarNode('lifetime')->defaultNull()->end()
|
|
|
|
->scalarNode('limit')->defaultNull()->end()
|
|
|
|
->end()
|
|
|
|
->end()
|
|
|
|
->end()
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2011-09-03 21:17:57 +02:00
|
|
|
private function addClientSection(ArrayNodeDefinition $rootNode)
|
|
|
|
{
|
|
|
|
$rootNode
|
|
|
|
->children()
|
|
|
|
->arrayNode('clients')
|
|
|
|
->useAttributeAsKey('name')
|
|
|
|
->prototype('array')
|
|
|
|
->children()
|
2011-09-04 23:43:20 +02:00
|
|
|
->scalarNode('wsdl')->isRequired()->end()
|
2011-10-08 22:04:18 +02:00
|
|
|
->scalarNode('namespace')->end()
|
|
|
|
->scalarNode('user_agent')->end()
|
2011-09-04 12:24:51 +02:00
|
|
|
->scalarNode('cache_type')
|
2011-09-04 02:42:53 +02:00
|
|
|
->validate()
|
|
|
|
->ifNotInArray($this->cacheTypes)
|
|
|
|
->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes)))
|
|
|
|
->end()
|
|
|
|
->end()
|
2011-10-08 18:03:27 +02:00
|
|
|
->arrayNode('classmap')
|
|
|
|
->useAttributeAsKey('name')
|
|
|
|
->prototype('scalar')
|
|
|
|
->end()
|
2011-09-03 21:17:57 +02:00
|
|
|
->end()
|
|
|
|
->end()
|
|
|
|
->end()
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2011-08-14 21:59:03 +02:00
|
|
|
private function addServicesSection(ArrayNodeDefinition $rootNode)
|
|
|
|
{
|
2011-03-26 16:43:41 +01:00
|
|
|
$rootNode
|
|
|
|
->children()
|
2011-04-07 21:49:01 +02:00
|
|
|
->arrayNode('services')
|
2011-07-14 18:39:47 +02:00
|
|
|
->useAttributeAsKey('name')
|
2011-04-07 21:49:01 +02:00
|
|
|
->prototype('array')
|
|
|
|
->children()
|
|
|
|
->scalarNode('namespace')
|
|
|
|
->isRequired()
|
|
|
|
->end()
|
|
|
|
->scalarNode('resource')
|
|
|
|
->defaultValue('*')
|
|
|
|
->end()
|
|
|
|
->scalarNode('resource_type')
|
|
|
|
->defaultValue('annotation')
|
|
|
|
->end()
|
|
|
|
->scalarNode('binding')
|
|
|
|
->defaultValue('document-wrapped')
|
|
|
|
->validate()
|
|
|
|
->ifNotInArray(array('rpc-literal', 'document-wrapped'))
|
|
|
|
->thenInvalid("Service binding style has to be either 'rpc-literal' or 'document-wrapped'")
|
|
|
|
->end()
|
|
|
|
->end()
|
2011-09-04 12:59:19 +02:00
|
|
|
->scalarNode('cache_type')
|
|
|
|
->validate()
|
|
|
|
->ifNotInArray($this->cacheTypes)
|
|
|
|
->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes)))
|
|
|
|
->end()
|
|
|
|
->end()
|
2011-04-07 21:49:01 +02:00
|
|
|
->end()
|
|
|
|
->end()
|
2011-03-26 16:43:41 +01:00
|
|
|
->end()
|
|
|
|
;
|
2011-08-14 21:59:03 +02:00
|
|
|
}
|
2011-03-26 16:43:41 +01:00
|
|
|
|
2011-08-14 21:59:03 +02:00
|
|
|
private function addWsdlDumperSection(ArrayNodeDefinition $rootNode)
|
|
|
|
{
|
|
|
|
$rootNode
|
|
|
|
->children()
|
|
|
|
->arrayNode('wsdl_dumper')
|
|
|
|
->addDefaultsIfNotSet()
|
|
|
|
->children()
|
|
|
|
->scalarNode('stylesheet')->defaultNull()
|
|
|
|
->end()
|
|
|
|
->end()
|
|
|
|
->end()
|
|
|
|
;
|
2011-03-26 16:43:41 +01:00
|
|
|
}
|
2011-07-14 17:45:03 +02:00
|
|
|
}
|