vendor/omines/datatables-bundle/src/DependencyInjection/Configuration.php line 26

Open in your IDE?
  1. <?php
  2. /*
  3.  * Symfony DataTables Bundle
  4.  * (c) Omines Internetbureau B.V. - https://omines.nl/
  5.  *
  6.  * For the full copyright and license information, please view the LICENSE
  7.  * file that was distributed with this source code.
  8.  */
  9. declare(strict_types=1);
  10. namespace Omines\DataTablesBundle\DependencyInjection;
  11. use Omines\DataTablesBundle\DataTable;
  12. use Omines\DataTablesBundle\Twig\TwigRenderer;
  13. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  14. use Symfony\Component\Config\Definition\ConfigurationInterface;
  15. use Symfony\Component\HttpFoundation\Request;
  16. class Configuration implements ConfigurationInterface
  17. {
  18.     /**
  19.      * @return TreeBuilder
  20.      */
  21.     public function getConfigTreeBuilder()
  22.     {
  23.         $treeBuilder = new TreeBuilder('datatables');
  24.         $rootNode $treeBuilder->getRootNode();
  25.         $rootNode
  26.             ->children()
  27.                 ->booleanNode('language_from_cdn')
  28.                     ->info('Load i18n data from DataTables CDN or locally')
  29.                     ->defaultTrue()
  30.                 ->end()
  31.                 ->enumNode('persist_state')
  32.                     ->info('Where to persist the current table state automatically')
  33.                     ->values(['none''query''fragment''local''session'])
  34.                     ->defaultValue('fragment')
  35.                 ->end()
  36.                 ->enumNode('method')
  37.                     ->info('Default HTTP method to be used for callbacks')
  38.                     ->values([Request::METHOD_GETRequest::METHOD_POST])
  39.                     ->defaultValue(Request::METHOD_POST)
  40.                 ->end()
  41.                 ->arrayNode('options')
  42.                     ->info('Default options to load into DataTables')
  43.                     ->useAttributeAsKey('option')
  44.                     ->prototype('variable')->end()
  45.                 ->end()
  46.                 ->scalarNode('renderer')
  47.                     ->info('Default service used to render templates, built-in TwigRenderer uses global Twig environment')
  48.                     ->defaultValue(TwigRenderer::class)
  49.                     ->cannotBeEmpty()
  50.                 ->end()
  51.                 ->scalarNode('template')
  52.                     ->info('Default template to be used for DataTables HTML')
  53.                     ->defaultValue(DataTable::DEFAULT_TEMPLATE)
  54.                     ->cannotBeEmpty()
  55.                 ->end()
  56.                 ->arrayNode('template_parameters')
  57.                     ->info('Default parameters to be passed to the template')
  58.                     ->addDefaultsIfNotSet()
  59.                     ->ignoreExtraKeys()
  60.                     ->children()
  61.                         ->scalarNode('className')
  62.                             ->info('Default class attribute to apply to the root table elements')
  63.                             ->defaultValue('table table-bordered')
  64.                             ->cannotBeEmpty()
  65.                         ->end()
  66.                         ->enumNode('columnFilter')
  67.                             ->info('If and where to enable the DataTables Filter module')
  68.                             ->values(['thead''tfoot''both'null])
  69.                             ->defaultNull()
  70.                         ->end()
  71.                     ->end()
  72.                 ->end()
  73.                 ->scalarNode('translation_domain')
  74.                     ->info('Default translation domain to be used')
  75.                     ->defaultValue('messages')
  76.                 ->end()
  77.             ->end()
  78.         ;
  79.         return $treeBuilder;
  80.     }
  81. }