vendor/sonata-project/exporter/src/Bridge/Symfony/DependencyInjection/Configuration.php line 29

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\Exporter\Bridge\Symfony\DependencyInjection;
  12. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  13. use Symfony\Component\Config\Definition\ConfigurationInterface;
  14. /**
  15.  * This is the class that validates and merges configuration from your app/config files.
  16.  *
  17.  * @author GrĂ©goire Paris <postmaster@greg0ire.fr>
  18.  */
  19. final class Configuration implements ConfigurationInterface
  20. {
  21.     public function getConfigTreeBuilder(): TreeBuilder
  22.     {
  23.         $treeBuilder = new TreeBuilder();
  24.         $rootNode $treeBuilder->root('sonata_exporter');
  25.         $rootNode
  26.             ->children()
  27.                 ->arrayNode('exporter')
  28.                     ->addDefaultsIfNotSet()
  29.                     ->children()
  30.                         ->arrayNode('default_writers')
  31.                             ->defaultValue(['csv''json''xls''xml'])
  32.                             ->prototype('scalar')->end()
  33.                         ->end()
  34.                     ->end()
  35.                 ->end()
  36.                 ->arrayNode('writers')
  37.                     ->addDefaultsIfNotSet()
  38.                     ->children()
  39.                         ->arrayNode('csv')
  40.                             ->addDefaultsIfNotSet()
  41.                             ->children()
  42.                                 ->scalarNode('filename')
  43.                                     ->defaultValue('php://output')
  44.                                     ->info('path to the output file')
  45.                                 ->end()
  46.                                 ->scalarNode('delimiter')
  47.                                     ->defaultValue(',')
  48.                                     ->info('delimits csv values')
  49.                                 ->end()
  50.                                 ->scalarNode('enclosure')
  51.                                     ->defaultValue('"')
  52.                                     ->info('will be used when a value contains the delimiter')
  53.                                 ->end()
  54.                                 ->scalarNode('escape')
  55.                                     ->defaultValue('\\')
  56.                                     ->info('will be used when a value contains the enclosure')
  57.                                 ->end()
  58.                                 ->booleanNode('show_headers')
  59.                                     ->defaultValue(true)
  60.                                     ->info('add column names as the first line')
  61.                                 ->end()
  62.                                 ->booleanNode('with_bom')
  63.                                     ->defaultValue(false)
  64.                                     ->info('include the byte order mark')
  65.                                 ->end()
  66.                             ->end()
  67.                         ->end()
  68.                         ->arrayNode('json')
  69.                             ->addDefaultsIfNotSet()
  70.                             ->children()
  71.                                 ->scalarNode('filename')
  72.                                     ->defaultValue('php://output')
  73.                                     ->info('path to the output file')
  74.                                 ->end()
  75.                             ->end()
  76.                         ->end()
  77.                         ->arrayNode('xls')
  78.                             ->addDefaultsIfNotSet()
  79.                             ->children()
  80.                                 ->scalarNode('filename')
  81.                                     ->defaultValue('php://output')
  82.                                     ->info('path to the output file')
  83.                                 ->end()
  84.                                 ->booleanNode('show_headers')
  85.                                     ->defaultValue(true)
  86.                                     ->info('add column names as the first line')
  87.                                 ->end()
  88.                             ->end()
  89.                         ->end()
  90.                         ->arrayNode('xml')
  91.                             ->addDefaultsIfNotSet()
  92.                             ->children()
  93.                                 ->scalarNode('filename')
  94.                                     ->defaultValue('php://output')
  95.                                     ->info('path to the output file')
  96.                                 ->end()
  97.                                 ->booleanNode('show_headers')
  98.                                     ->defaultValue(true)
  99.                                     ->info('add column names as the first line')
  100.                                 ->end()
  101.                                 ->scalarNode('main_element')
  102.                                     ->defaultValue('datas')
  103.                                     ->info('name of the wrapping element')
  104.                                 ->end()
  105.                                 ->scalarNode('child_element')
  106.                                     ->defaultValue('data')
  107.                                     ->info('name of elements corresponding to rows')
  108.                                 ->end()
  109.                             ->end()
  110.                         ->end()
  111.                     ->end()
  112.                 ->end()
  113.             ->end()
  114.         ;
  115.         return $treeBuilder;
  116.     }
  117. }