vendor/stfalcon/tinymce-bundle/Stfalcon/Bundle/TinymceBundle/DependencyInjection/Configuration.php line 25

Open in your IDE?
  1. <?php
  2. namespace Stfalcon\Bundle\TinymceBundle\DependencyInjection;
  3. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  4. use Symfony\Component\Config\Definition\ConfigurationInterface;
  5. /**
  6.  * Configuration.
  7.  */
  8. class Configuration implements ConfigurationInterface
  9. {
  10.     /**
  11.      * Generates the configuration tree.
  12.      *
  13.      * @return TreeBuilder
  14.      */
  15.     public function getConfigTreeBuilder(): TreeBuilder
  16.     {
  17.         $defaults $this->getTinymceDefaults();
  18.         $treeBuilder = new TreeBuilder();
  19.         return $treeBuilder
  20.             ->root('stfalcon_tinymce''array')
  21.                 ->children()
  22.                     // Include jQuery (true) library or not (false)
  23.                     ->booleanNode('include_jquery')->defaultFalse()->end()
  24.                     // Use jQuery (true) or standalone (false) build of the TinyMCE
  25.                     ->booleanNode('tinymce_jquery')->defaultFalse()->end()
  26.                     // Set init to true to use callback on the event init
  27.                     ->booleanNode('use_callback_tinymce_init')->defaultFalse()->end()
  28.                     // Selector
  29.                     ->scalarNode('selector')->defaultValue('.tinymce')->end()
  30.                     // base url for content
  31.                     ->scalarNode('base_url')->end()
  32.                     // asset packageName
  33.                     ->scalarNode('asset_package_name')->end()
  34.                     // Default language for all instances of the editor
  35.                     ->scalarNode('language')->defaultNull()->end()
  36.                     ->arrayNode('theme')
  37.                         ->useAttributeAsKey('name')
  38.                         ->prototype('array')
  39.                             ->useAttributeAsKey('name')
  40.                             ->prototype('variable')->end()
  41.                         ->end()
  42.                         // Add default theme if it doesn't set
  43.                         ->defaultValue($defaults)
  44.                     ->end()
  45.                     // Configure custom TinyMCE buttons
  46.                     ->arrayNode('tinymce_buttons')
  47.                         ->useAttributeAsKey('name')
  48.                         ->prototype('array')
  49.                             ->addDefaultsIfNotSet()
  50.                             ->children()
  51.                                 ->scalarNode('text')->defaultNull()->end()
  52.                                 ->scalarNode('title')->defaultNull()->end()
  53.                                 ->scalarNode('image')->defaultNull()->end()
  54.                                 ->scalarNode('icon')->defaultNull()->end()
  55.                             ->end()
  56.                         ->end()
  57.                     ->end()
  58.                     // Configure external TinyMCE plugins
  59.                     ->arrayNode('external_plugins')
  60.                         ->useAttributeAsKey('name')
  61.                         ->prototype('array')
  62.                             ->addDefaultsIfNotSet()
  63.                             ->children()
  64.                                 ->scalarNode('url')->isRequired()->end()
  65.                             ->end()
  66.                         ->end()
  67.                     ->end()
  68.                 ->end()
  69.             ->end();
  70.     }
  71.     /**
  72.      * Get default configuration of the each instance of editor
  73.      *
  74.      * @return array
  75.      */
  76.     private function getTinymceDefaults(): array
  77.     {
  78.         return [
  79.             'advanced' => [
  80.                 'theme' => 'modern',
  81.                 'plugins' => [
  82.                     'advlist autolink lists link image charmap print preview hr anchor pagebreak',
  83.                     'searchreplace wordcount visualblocks visualchars code fullscreen',
  84.                     'insertdatetime media nonbreaking save table contextmenu directionality',
  85.                     'emoticons template paste textcolor',
  86.                 ],
  87.                 'toolbar1' => 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify
  88.                                    | bullist numlist outdent indent | link image',
  89.                 'toolbar2' => 'print preview media | forecolor backcolor emoticons',
  90.                 'image_advtab' => true,
  91.             ],
  92.             'simple' => [],
  93.         ];
  94.     }
  95. }