vendor/friendsofsymfony/ckeditor-bundle/src/DependencyInjection/Configuration.php line 189

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the FOSCKEditor Bundle.
  4.  *
  5.  * (c) 2018 - present  Friends of Symfony
  6.  * (c) 2009 - 2017     Eric GELOEN <geloen.eric@gmail.com>
  7.  *
  8.  * For the full copyright and license information, please read the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace FOS\CKEditorBundle\DependencyInjection;
  12. use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
  13. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  14. use Symfony\Component\Config\Definition\ConfigurationInterface;
  15. /**
  16.  * @author GeLo <geloen.eric@gmail.com>
  17.  */
  18. class Configuration implements ConfigurationInterface
  19. {
  20.     /**
  21.      * {@inheritdoc}
  22.      */
  23.     public function getConfigTreeBuilder()
  24.     {
  25.         $treeBuilder $this->createTreeBuilder();
  26.         $treeBuilder
  27.             ->root('fos_ck_editor')
  28.             ->children()
  29.                 ->booleanNode('enable')->end()
  30.                 ->booleanNode('async')->end()
  31.                 ->booleanNode('auto_inline')->end()
  32.                 ->booleanNode('inline')->end()
  33.                 ->booleanNode('autoload')->end()
  34.                 ->booleanNode('jquery')->end()
  35.                 ->booleanNode('require_js')->end()
  36.                 ->booleanNode('input_sync')->end()
  37.                 ->scalarNode('base_path')->end()
  38.                 ->scalarNode('js_path')->end()
  39.                 ->scalarNode('jquery_path')->end()
  40.                 ->scalarNode('default_config')->end()
  41.                 ->append($this->createConfigsNode())
  42.                 ->append($this->createPluginsNode())
  43.                 ->append($this->createStylesNode())
  44.                 ->append($this->createTemplatesNode())
  45.                 ->append($this->createFilebrowsersNode())
  46.                 ->append($this->createToolbarsNode())
  47.             ->end();
  48.         return $treeBuilder;
  49.     }
  50.     /**
  51.      * @return ArrayNodeDefinition
  52.      */
  53.     private function createConfigsNode()
  54.     {
  55.         return $this->createPrototypeNode('configs')
  56.             ->prototype('array')
  57.                 ->normalizeKeys(false)
  58.                 ->useAttributeAsKey('name')
  59.                 ->prototype('variable')->end()
  60.             ->end();
  61.     }
  62.     /**
  63.      * @return ArrayNodeDefinition
  64.      */
  65.     private function createPluginsNode()
  66.     {
  67.         return $this->createPrototypeNode('plugins')
  68.             ->prototype('array')
  69.                 ->children()
  70.                     ->scalarNode('path')->end()
  71.                     ->scalarNode('filename')->end()
  72.                 ->end()
  73.             ->end();
  74.     }
  75.     /**
  76.      * @return ArrayNodeDefinition
  77.      */
  78.     private function createStylesNode()
  79.     {
  80.         return $this->createPrototypeNode('styles')
  81.             ->prototype('array')
  82.                 ->prototype('array')
  83.                     ->children()
  84.                         ->scalarNode('name')->end()
  85.                         ->scalarNode('type')->end()
  86.                         ->scalarNode('widget')->end()
  87.                         ->variableNode('element')->end()
  88.                         ->append($this->createPrototypeNode('styles')->prototype('scalar')->end())
  89.                         ->append($this->createPrototypeNode('attributes')->prototype('scalar')->end())
  90.                     ->end()
  91.                 ->end()
  92.             ->end();
  93.     }
  94.     /**
  95.      * @return ArrayNodeDefinition
  96.      */
  97.     private function createTemplatesNode()
  98.     {
  99.         return $this->createPrototypeNode('templates')
  100.             ->prototype('array')
  101.                 ->children()
  102.                     ->scalarNode('imagesPath')->end()
  103.                     ->arrayNode('templates')
  104.                         ->prototype('array')
  105.                             ->children()
  106.                                 ->scalarNode('title')->end()
  107.                                 ->scalarNode('image')->end()
  108.                                 ->scalarNode('description')->end()
  109.                                 ->scalarNode('html')->end()
  110.                                 ->scalarNode('template')->end()
  111.                                 ->append($this->createPrototypeNode('template_parameters')->prototype('scalar')->end())
  112.                             ->end()
  113.                         ->end()
  114.                     ->end()
  115.                 ->end()
  116.             ->end();
  117.     }
  118.     /**
  119.      * @return ArrayNodeDefinition
  120.      */
  121.     private function createFilebrowsersNode()
  122.     {
  123.         return $this->createNode('filebrowsers')
  124.             ->useAttributeAsKey('name')
  125.             ->prototype('scalar')
  126.             ->end();
  127.     }
  128.     /**
  129.      * @return ArrayNodeDefinition
  130.      */
  131.     private function createToolbarsNode()
  132.     {
  133.         return $this->createNode('toolbars')
  134.             ->addDefaultsIfNotSet()
  135.             ->children()
  136.                 ->arrayNode('configs')
  137.                     ->useAttributeAsKey('name')
  138.                     ->prototype('array')
  139.                         ->prototype('variable')->end()
  140.                     ->end()
  141.                 ->end()
  142.                 ->arrayNode('items')
  143.                     ->useAttributeAsKey('name')
  144.                     ->prototype('array')
  145.                         ->prototype('variable')->end()
  146.                     ->end()
  147.                 ->end()
  148.             ->end();
  149.     }
  150.     /**
  151.      * @param string $name
  152.      *
  153.      * @return ArrayNodeDefinition
  154.      */
  155.     private function createPrototypeNode($name)
  156.     {
  157.         return $this->createNode($name)
  158.             ->normalizeKeys(false)
  159.             ->useAttributeAsKey('name');
  160.     }
  161.     /**
  162.      * @param string $name
  163.      *
  164.      * @return ArrayNodeDefinition
  165.      */
  166.     private function createNode($name)
  167.     {
  168.         return $this->createTreeBuilder()->root($name);
  169.     }
  170.     /**
  171.      * @return TreeBuilder
  172.      */
  173.     private function createTreeBuilder()
  174.     {
  175.         return new TreeBuilder();
  176.     }
  177. }