Jordi Boggiano 28f059fff0 Merge pull request #86 from vslinko/allow-to-disable-inline-doc
Make request listener configurable
2012-10-19 01:05:37 -07:00

75 lines
3.0 KiB
PHP

<?php
/*
* This file is part of the NelmioApiDocBundle.
*
* (c) Nelmio <hello@nelm.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Nelmio\ApiDocBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$treeBuilder
->root('nelmio_api_doc')
->children()
->scalarNode('name')->defaultValue('API documentation')->end()
->arrayNode('request_listener')
->beforeNormalization()
->ifTrue(function ($a) { return is_bool($a); })
->then(function ($a) { return array('enabled' => $a); })
->end()
->addDefaultsIfNotSet()
->children()
->booleanNode('enabled')->defaultTrue()->end()
->scalarNode('parameter')->defaultValue('_doc')->end()
->end()
->end()
->arrayNode('sandbox')
->addDefaultsIfNotSet()
->children()
->scalarNode('enabled')->defaultTrue()->end()
->scalarNode('endpoint')->defaultValue('/app_dev.php')->end()
->arrayNode('request_format')
->addDefaultsIfNotSet()
->children()
->enumNode('method')
->values(array('format_param', 'accept_header'))
->defaultValue('format_param')
->end()
->enumNode('default_format')
->values(array('json', 'xml'))
->defaultValue('json')
->end()
->end()
->end()
->arrayNode('authentication')
->children()
->scalarNode('name')->isRequired()->end()
->scalarNode('delivery')
->isRequired()
->validate()
// header|query|request, but only query is implemented for now
->ifNotInArray(array('query'))
->thenInvalid("Unknown authentication delivery type '%s'.")
->end()
->end()
->end()
->end()
->end()
->end()
->end();
return $treeBuilder;
}
}