vendor/symfony-cmf/routing-auto-bundle/src/DependencyInjection/Configuration.php line 64

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony CMF package.
  4.  *
  5.  * (c) 2011-2015 Symfony CMF
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Cmf\Bundle\RoutingAutoBundle\DependencyInjection;
  11. use Symfony\Cmf\Component\RoutingAuto\UriGenerator;
  12. use Symfony\Component\Config\Definition\ConfigurationInterface;
  13. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  14. class Configuration implements ConfigurationInterface
  15. {
  16.     const DEFAULT_URI_GENERATOR UriGenerator::class;
  17.     /**
  18.      * Returns the config tree builder.
  19.      *
  20.      * @return TreeBuilder
  21.      */
  22.     public function getConfigTreeBuilder()
  23.     {
  24.         $treeBuilder = new TreeBuilder();
  25.         $treeBuilder->root('cmf_routing_auto')
  26.             ->addDefaultsIfNotSet()
  27.             ->children()
  28.                 ->scalarNode('adapter')->info('Use a specific adapter, overrides any implicit selection')->end()
  29.                 ->scalarNode('uri_generator')->defaultValue(self::DEFAULT_URI_GENERATOR)->end()
  30.                 ->booleanNode('auto_mapping')->defaultTrue()->end()
  31.                 ->arrayNode('mapping')
  32.                     ->fixXmlConfig('resource')
  33.                     ->children()
  34.                         ->arrayNode('resources')
  35.                             ->prototype('array')
  36.                                 ->beforeNormalization()
  37.                                     ->ifString()
  38.                                     ->then(function ($v) {
  39.                                         return array('path' => $v);
  40.                                     })
  41.                                 ->end()
  42.                                 ->children()
  43.                                     ->scalarNode('path')->isRequired()->end()
  44.                                     ->scalarNode('type')->defaultNull()->end()
  45.                                 ->end()
  46.                             ->end()
  47.                         ->end() // directories
  48.                     ->end()
  49.                 ->end() // mapping
  50.                 ->append($this->getPersistenceNode())
  51.             ->end();
  52.         return $treeBuilder;
  53.     }
  54.     protected function getPersistenceNode()
  55.     {
  56.         $builder = new TreeBuilder();
  57.         $persistence $builder->root('persistence');
  58.         $persistence
  59.             ->addDefaultsIfNotSet()
  60.             ->children()
  61.                 ->arrayNode('phpcr')
  62.                     ->addDefaultsIfNotSet()
  63.                     ->canBeEnabled()
  64.                     ->children()
  65.                         ->scalarNode('route_basepath')->defaultValue('/cms/routes')->cannotBeEmpty()->end()
  66.                     ->end()
  67.                 ->end() // phpcr
  68.                 ->arrayNode('orm')
  69.                     ->addDefaultsIfNotSet()
  70.                     ->canBeEnabled()
  71.                 ->end() // orm
  72.             ->end();
  73.         return $persistence;
  74.     }
  75. }