vendor/sonata-project/translation-bundle/src/DependencyInjection/Configuration.php line 104

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of the Sonata Project package.
  5.  *
  6.  * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  7.  *
  8.  * For the full copyright and license information, please view the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace Sonata\TranslationBundle\DependencyInjection;
  12. use Sonata\TranslationBundle\Enum\TranslationFilterMode;
  13. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  14. use Symfony\Component\Config\Definition\ConfigurationInterface;
  15. /**
  16.  * @final since sonata-project/translation-bundle 2.7
  17.  *
  18.  * @author Nicolas Bastien <nbastien.pro@gmail.com>
  19.  */
  20. class Configuration implements ConfigurationInterface
  21. {
  22.     public function getConfigTreeBuilder()
  23.     {
  24.         $treeBuilder = new TreeBuilder('sonata_translation');
  25.         $rootNode $treeBuilder->getRootNode();
  26.         $rootNode
  27.             ->children()
  28.                 ->arrayNode('locales')
  29.                     ->info('The list of your frontend locales in which your models will be translatable.')
  30.                     ->requiresAtLeastOneElement()
  31.                     ->prototype('scalar')->end()
  32.                 ->end()
  33.                 ->scalarNode('default_locale')
  34.                     ->defaultValue('en')
  35.                     ->info('The frontend locale that is used by default.')
  36.                 ->end()
  37.                 ->enumNode('default_filter_mode')
  38.                     ->values(TranslationFilterMode::AVAILABLE_FILTER_TYPES)
  39.                     ->defaultValue(TranslationFilterMode::GEDMO)
  40.                     ->info('The filter mode that is used by default.')
  41.                 ->end()
  42.                 ->arrayNode('gedmo')
  43.                     ->canBeEnabled()
  44.                     ->children()
  45.                         ->arrayNode('implements')
  46.                             ->requiresAtLeastOneElement()
  47.                             ->prototype('scalar')->end()
  48.                         ->end()
  49.                         ->arrayNode('instanceof')
  50.                             ->requiresAtLeastOneElement()
  51.                             ->prototype('scalar')->end()
  52.                         ->end()
  53.                     ->end()
  54.                 ->end()
  55.                 ->arrayNode('knplabs')
  56.                     ->canBeEnabled()
  57.                     ->children()
  58.                         ->arrayNode('implements')
  59.                             ->requiresAtLeastOneElement()
  60.                             ->prototype('scalar')->end()
  61.                         ->end()
  62.                         ->arrayNode('instanceof')
  63.                             ->requiresAtLeastOneElement()
  64.                             ->prototype('scalar')->end()
  65.                         ->end()
  66.                     ->end()
  67.                 ->end()
  68.                 ->arrayNode('phpcr')
  69.                     ->canBeEnabled()
  70.                     ->children()
  71.                         ->arrayNode('implements')
  72.                             ->requiresAtLeastOneElement()
  73.                             ->prototype('scalar')->end()
  74.                         ->end()
  75.                         ->arrayNode('instanceof')
  76.                             ->requiresAtLeastOneElement()
  77.                             ->prototype('scalar')->end()
  78.                         ->end()
  79.                     ->end()
  80.                 ->end()
  81.                 ->booleanNode('locale_switcher')
  82.                     ->info('Enable the global locale switcher services.')
  83.                     ->defaultFalse()
  84.                 ->end()
  85.                 // NEXT_MAJOR: Fix locale to country flag mapping OR remove country flags entirely
  86.                 ->booleanNode('locale_switcher_show_country_flags')
  87.                     ->info('Whether the language switcher should show languages as flags')
  88.                     ->defaultTrue()
  89.                 ->end()
  90.             ->end()
  91.             ->beforeNormalization()
  92.                 ->ifTrue(static function ($v) {return !isset($v['locale_switcher_show_country_flags']) || true === $v['locale_switcher_show_country_flags']; })
  93.                 ->then(static function ($v) {
  94.                     @trigger_error(sprintf(
  95.                         'Showing the country flags is deprecated. The flags will be removed in the next major version. Please set "%s" to false to avoid this message.',
  96.                         'sonata_translation.locale_switcher_show_country_flags'
  97.                     ), E_USER_DEPRECATED);
  98.                     $v['locale_switcher_show_country_flags'] = $v['locale_switcher_show_country_flags'] ?? true;
  99.                     return $v;
  100.                 })
  101.             ->end();
  102.         return $treeBuilder;
  103.     }
  104. }