<?php
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* FrameworkExtension configuration structure.
*
* @author Jeremy Mikola <jmikola@gmail.com>
*/
class Configuration implements ConfigurationInterface
{
private $debug;
* Constructor
* @param Boolean $debug Whether to use the debug mode
public function __construct($debug)
$this->debug = (Boolean) $debug;
}
* Generates the configuration tree builder.
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
public function getConfigTreeBuilder()
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('framework');
$rootNode
->children()
->scalarNode('cache_warmer')->defaultValue(!$this->debug)->end()
->scalarNode('charset')->end()
->scalarNode('secret')->isRequired()->end()
->scalarNode('error_handler')->end()
->scalarNode('exception_controller')->defaultValue('Symfony\\Bundle\\FrameworkBundle\\Controller\\ExceptionController::showAction')->end()
->scalarNode('ide')->defaultNull()->end()
->booleanNode('test')->end()
->end()
;
$this->addCsrfProtectionSection($rootNode);
$this->addEsiSection($rootNode);
$this->addProfilerSection($rootNode);
$this->addRouterSection($rootNode);
$this->addSessionSection($rootNode);
$this->addTemplatingSection($rootNode);
$this->addTranslatorSection($rootNode);
$this->addValidationSection($rootNode);
return $treeBuilder;
private function addCsrfProtectionSection(ArrayNodeDefinition $rootNode)
->arrayNode('csrf_protection')
->canBeUnset()
->treatNullLike(array('enabled' => true))
->treatTrueLike(array('enabled' => true))
->booleanNode('enabled')->defaultTrue()->end()
->scalarNode('field_name')->defaultValue('_token')->end()
private function addEsiSection(ArrayNodeDefinition $rootNode)
->arrayNode('esi')
->booleanNode('enabled')->end()
private function addProfilerSection(ArrayNodeDefinition $rootNode)
->arrayNode('profiler')
->booleanNode('only_exceptions')->defaultFalse()->end()
->booleanNode('only_master_requests')->defaultFalse()->end()
->scalarNode('dsn')->defaultValue('sqlite:%kernel.cache_dir%/profiler.db')->end()
->scalarNode('username')->defaultValue('')->end()
->scalarNode('password')->defaultValue('')->end()
->scalarNode('lifetime')->defaultValue(86400)->end()
->arrayNode('matcher')
->performNoDeepMerging()
->scalarNode('ip')->end()
->scalarNode('path')->end()
->scalarNode('service')->end()
private function addRouterSection(ArrayNodeDefinition $rootNode)
->arrayNode('router')
->scalarNode('cache_warmer')->defaultFalse()->end()
->scalarNode('resource')->isRequired()->end()
->scalarNode('type')->end()
->scalarNode('http_port')->defaultValue(80)->end()
->scalarNode('https_port')->defaultValue(443)->end()
private function addSessionSection(ArrayNodeDefinition $rootNode)
->arrayNode('session')
->booleanNode('auto_start')->end()
->scalarNode('default_locale')->defaultValue('en')->end()
->scalarNode('storage_id')->defaultValue('session.storage.native')->end()
->scalarNode('name')->end()
->scalarNode('lifetime')->end()
->scalarNode('domain')->end()
->booleanNode('secure')->end()
->booleanNode('httponly')->end()
private function addTemplatingSection(ArrayNodeDefinition $rootNode)
->arrayNode('templating')
->scalarNode('assets_version')->defaultValue(null)->end()
->fixXmlConfig('assets_base_url')
->arrayNode('assets_base_urls')
->beforeNormalization()
->ifTrue(function($v){ return !is_array($v); })
->then(function($v){ return array($v); })
->prototype('scalar')->end()
->scalarNode('cache')->end()
->fixXmlConfig('engine')
->arrayNode('engines')
->isRequired()
->requiresAtLeastOneElement()
->fixXmlConfig('loader')
->arrayNode('loaders')
->fixXmlConfig('package')
->arrayNode('packages')
->useAttributeAsKey('name')
->prototype('array')
->fixXmlConfig('base_url')
->scalarNode('version')->defaultNull()->end()
->arrayNode('base_urls')
private function addTranslatorSection(ArrayNodeDefinition $rootNode)
->arrayNode('translator')
->scalarNode('fallback')->defaultValue('en')->end()
private function addValidationSection(ArrayNodeDefinition $rootNode)
->arrayNode('validation')
->booleanNode('enable_annotations')->defaultFalse()->end()