vendor/wearemarketing/blockbundle/DependencyInjection/Configuration.php line 22

Open in your IDE?
  1. <?php
  2. namespace WAM\Bundle\BlockBundle\DependencyInjection;
  3. use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  4. use Symfony\Component\Config\Definition\ConfigurationInterface;
  5. use WAM\Bundle\BlockBundle\Entity\Types\CollectionBlock;
  6. /**
  7.  * This is the class that validates and merges configuration from your app/config files.
  8.  *
  9.  * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
  10.  */
  11. class Configuration implements ConfigurationInterface
  12. {
  13.     /**
  14.      * {@inheritdoc}
  15.      */
  16.     public function getConfigTreeBuilder()
  17.     {
  18.         $treeBuilder = new TreeBuilder();
  19.         $rootNode $treeBuilder->root('wam_block');
  20.         $rootNode
  21.             ->children()
  22.                 ->scalarNode('class')->defaultValue('WAM\Bundle\BlockBundle\Entity\AbstractBlock')->end()
  23.                 ->arrayNode('custom_types')
  24.                     ->defaultValue(array())
  25.                     ->prototype('scalar')->end()
  26.                 ->end()
  27.                 ->arrayNode('templates')
  28.                     ->useAttributeAsKey('namespace'true)
  29.                         ->prototype('variable')
  30.                             ->validate()
  31.                                 ->ifTrue(function ($value) {
  32.                                     if (!is_array($value)) {
  33.                                         return true;
  34.                                     }
  35.                                     foreach ($value as $item) {
  36.                                         if (!in_array('source'array_keys($item))) {
  37.                                             return true;
  38.                                         }
  39.                                         if (!in_array('name'array_keys($item))) {
  40.                                             return true;
  41.                                         }
  42.                                         if (!in_array('icon_class'array_keys($item))) {
  43.                                             return true;
  44.                                         }
  45.                                     }
  46.                                 })
  47.                                 ->thenInvalid('Invalid templates configuration')
  48.                             ->end()
  49.                         ->end()
  50.                 ->end()
  51.                 ->arrayNode('global_templates')
  52.                     ->defaultValue(array())
  53.                     ->prototype('array')
  54.                         ->children()
  55.                             ->scalarNode('name')->end()
  56.                             ->scalarNode('icon_class')->end()
  57.                             ->scalarNode('source')->end()
  58.                         ->end()
  59.                     ->end()
  60.                 ->end()
  61.                 ->arrayNode('ckeditor')
  62.                     ->addDefaultsIfNotSet()
  63.                     ->children()
  64.                         ->scalarNode('default')
  65.                         ->defaultValue('default')->end()
  66.                         ->arrayNode('blocks')
  67.                             ->defaultValue(array())
  68.                             ->prototype('scalar')->end()
  69.                         ->end()
  70.                     ->end()
  71.                 ->end()
  72.                 ->arrayNode('collection_block')
  73.                     ->addDefaultsIfNotSet()
  74.                     ->children()
  75.                         ->arrayNode('entities')
  76.                             ->defaultValue(array())
  77.                             ->useAttributeAsKey('namespace')
  78.                             ->prototype('array')
  79.                                 ->children()
  80.                                     ->scalarNode('name_to_show')->end()
  81.                                     ->scalarNode('prefix')->end()
  82.                                     ->arrayNode('order_fields')
  83.                                         ->defaultValue(array())
  84.                                         ->prototype('scalar')->end()
  85.                                     ->end()
  86.                                     ->arrayNode('special_fields')
  87.                                         ->useAttributeAsKey('entity_special_field')
  88.                                         ->prototype('array')
  89.                                             ->children()
  90.                                                 ->scalarNode('name')->end()
  91.                                                 ->scalarNode('type')->end()
  92.                                                 ->scalarNode('class')->end()
  93.                                                 ->scalarNode('choices_class')->end()
  94.                                                 ->scalarNode('choices_static_method')->end()
  95.                                                 ->scalarNode('operator')->defaultValue(CollectionBlock::OPERATOR_EQUALS)->end()
  96.                                             ->end()
  97.                                         ->end()
  98.                                     ->end()
  99.                                 ->end()
  100.                             ->end()
  101.                         ->end()
  102.                     ->end()
  103.                 ->end()
  104.             ->end();
  105.         return $treeBuilder;
  106.     }
  107. }