vendor/lexik/translation-bundle/DependencyInjection/Configuration.php line 25

Open in your IDE?
  1. <?php
  2. namespace Lexik\Bundle\TranslationBundle\DependencyInjection;
  3. use Lexik\Bundle\TranslationBundle\Storage\StorageInterface;
  4. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  5. use Symfony\Component\Config\Definition\ConfigurationInterface;
  6. /**
  7.  * This is the class that validates and merges configuration from your app/config files
  8.  *
  9.  * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
  10.  *
  11.  * @author Cédric Girard <c.girard@lexik.fr>
  12.  */
  13. class Configuration implements ConfigurationInterface
  14. {
  15.     /**
  16.      * (non-PHPdoc)
  17.      * @see Symfony\Component\Config\Definition.ConfigurationInterface::getConfigTreeBuilder()
  18.      */
  19.     public function getConfigTreeBuilder()
  20.     {
  21.         $treeBuilder = new TreeBuilder();
  22.         $rootNode $treeBuilder->root('lexik_translation');
  23.         $storages = array(
  24.             StorageInterface::STORAGE_ORM,
  25.             StorageInterface::STORAGE_MONGODB,
  26.             StorageInterface::STORAGE_PROPEL,
  27.         );
  28.         $registrationTypes = array('all''files''database');
  29.         $inputTypes = array('text''textarea');
  30.         $rootNode
  31.             ->addDefaultsIfNotSet()
  32.             ->children()
  33.                 ->scalarNode('base_layout')
  34.                     ->cannotBeEmpty()
  35.                     ->defaultValue('@LexikTranslationBundle/layout.html.twig')
  36.                 ->end()
  37.                 ->arrayNode('fallback_locale')
  38.                     ->isRequired()
  39.                     ->requiresAtLeastOneElement()
  40.                     ->prototype('scalar')->end()
  41.                     ->beforeNormalization()
  42.                         ->ifString()
  43.                         ->then(function ($value) { return array($value); })
  44.                     ->end()
  45.                 ->end()
  46.                 ->arrayNode('managed_locales')
  47.                     ->isRequired()
  48.                     ->requiresAtLeastOneElement()
  49.                     ->prototype('scalar')->end()
  50.                 ->end()
  51.                 ->scalarNode('grid_input_type')
  52.                     ->cannotBeEmpty()
  53.                     ->defaultValue('text')
  54.                     ->validate()
  55.                         ->ifNotInArray($inputTypes)
  56.                         ->thenInvalid('The input type "%s" is not supported. Please use one of the following types: '.implode(', '$inputTypes))
  57.                     ->end()
  58.                 ->end()
  59.                 ->booleanNode('grid_toggle_similar')
  60.                     ->defaultValue(false)
  61.                 ->end()
  62.                 ->booleanNode('auto_cache_clean')
  63.                     ->defaultValue(false)
  64.                 ->end()
  65.                 ->integerNode('auto_cache_clean_interval')
  66.                     ->defaultValue(null)
  67.                 ->end()
  68.                 ->arrayNode('storage')
  69.                     ->addDefaultsIfNotSet()
  70.                     ->children()
  71.                         ->scalarNode('type')
  72.                             ->cannotBeEmpty()
  73.                             ->defaultValue(StorageInterface::STORAGE_ORM)
  74.                             ->validate()
  75.                                 ->ifNotInArray($storages)
  76.                                 ->thenInvalid('The storage "%s" is not supported. Please use one of the following storage: '.implode(', '$storages))
  77.                             ->end()
  78.                         ->end()
  79.                         ->scalarNode('object_manager')
  80.                         ->end()
  81.                     ->end()
  82.                 ->end()
  83.                 ->arrayNode('resources_registration')
  84.                     ->addDefaultsIfNotSet()
  85.                     ->children()
  86.                         ->scalarNode('type')
  87.                             ->cannotBeEmpty()
  88.                             ->defaultValue('all')
  89.                             ->validate()
  90.                                 ->ifNotInArray($registrationTypes)
  91.                                 ->thenInvalid('Invalid registration type "%s". Please use one of the following types: '.implode(', '$registrationTypes))
  92.                             ->end()
  93.                         ->end()
  94.                         ->booleanNode('managed_locales_only')
  95.                             ->defaultTrue()
  96.                         ->end()
  97.                     ->end()
  98.                 ->end()
  99.                 ->arrayNode('exporter')
  100.                     ->addDefaultsIfNotSet()
  101.                     ->children()
  102.                         ->booleanNode('json_hierarchical_format')
  103.                             ->defaultFalse()
  104.                         ->end()
  105.                         ->booleanNode('use_yml_tree')
  106.                             ->defaultFalse()
  107.                         ->end()
  108.                     ->end()
  109.                 ->end()
  110.                 ->arrayNode('dev_tools')
  111.                     ->addDefaultsIfNotSet()
  112.                     ->children()
  113.                         ->booleanNode('enable')
  114.                             ->defaultFalse()
  115.                         ->end()
  116.                         ->booleanNode('create_missing')
  117.                             ->defaultFalse()
  118.                         ->end()
  119.                         ->scalarNode('file_format')
  120.                             ->defaultValue('yml')
  121.                         ->end()
  122.                     ->end()
  123.                 ->end()
  124.             ->end()
  125.         ;
  126.         return $treeBuilder;
  127.     }
  128. }