vendor/sonata-project/formatter-bundle/src/DependencyInjection/Configuration.php line 28

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sonata Project package.
  4.  *
  5.  * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  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 Sonata\FormatterBundle\DependencyInjection;
  11. use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
  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.  * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
  18.  */
  19. class Configuration implements ConfigurationInterface
  20. {
  21.     public function getConfigTreeBuilder()
  22.     {
  23.         $treeBuilder = new TreeBuilder();
  24.         $rootNode $treeBuilder->root('sonata_formatter');
  25.         $rootNode
  26.             ->children()
  27.                 ->scalarNode('default_formatter')->end() // NEXT_MAJOR: make this required
  28.                 ->arrayNode('formatters')
  29.                     ->useAttributeAsKey('name')
  30.                     ->prototype('array')
  31.                         ->children()
  32.                             ->scalarNode('service')->isRequired()->end()
  33.                             ->arrayNode('extensions')
  34.                                 ->prototype('scalar')
  35.                                 ->end()
  36.                         ->end()
  37.                     ->end()
  38.                 ->end()
  39.             ->end()
  40.         ;
  41.         $this->addCkeditorSection($rootNode);
  42.         return $treeBuilder;
  43.     }
  44.     private function addCkeditorSection(ArrayNodeDefinition $node)
  45.     {
  46.         $node
  47.             ->children()
  48.                 ->arrayNode('ckeditor')
  49.                 ->addDefaultsIfNotSet()
  50.                     ->children()
  51.                         ->arrayNode('templates')
  52.                             ->addDefaultsIfNotSet()
  53.                             ->children()
  54.                                 ->scalarNode('browser')->defaultValue('@SonataFormatter/Ckeditor/browser.html.twig')->cannotBeEmpty()->end()
  55.                                 ->scalarNode('upload')->defaultValue('@SonataFormatter/Ckeditor/upload.html.twig')->cannotBeEmpty()->end()
  56.                         ->end()
  57.                     ->end()
  58.                 ->end()
  59.             ->end()
  60.         ;
  61.     }
  62. }