]> Raphaël G. Git Repositories - airbundle/blobdiff - DependencyInjection/Configuration.php
Fix configuration tree
[airbundle] / DependencyInjection / Configuration.php
index 9be5f157c174345a808d28771bc49ab7e175a15d..9b1c3a33c01f02b97e6a0d8d09c88f863347afc7 100644 (file)
@@ -11,21 +11,29 @@ use Symfony\Component\Config\Definition\ConfigurationInterface;
  * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
  */
 class Configuration implements ConfigurationInterface {
  * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
  */
 class Configuration implements ConfigurationInterface {
-    /**
-     * {@inheritdoc}
-     */
-    public function getConfigTreeBuilder() {
-        $treeBuilder = new TreeBuilder('parameters');
+       /**
+        * {@inheritdoc}
+        */
+       public function getConfigTreeBuilder() {
+               $treeBuilder = new TreeBuilder('rapsys_air');
 
 
-        // Here you should define the parameters that are allowed to
-        // configure your bundle. See the documentation linked above for
-        // more information on that topic.
+               // Here you should define the parameters that are allowed to
+               // configure your bundle. See the documentation linked above for
+               // more information on that topic.
                //Set defaults
                $defaults = [
                //Set defaults
                $defaults = [
-                       'logo' => 'bundles/rapsysair/png/logo.png',
-                       'title' => 'Open Air',
-                       'contact_name' => 'Raphaël Gertz',
-                       'contact_mail' => 'airlibre@rapsys.eu',
+                       'site' => [
+                               'logo' => '@RapsysAir/../public/png/logo.png',
+                               'title' => 'Air Libre'
+                       ],
+                       'copy' => [
+                               'long' => 'John Doe all rights reserved',
+                               'short' => 'Copyright 2019'
+                       ],
+                       'contact' => [
+                               'name' => 'John Doe',
+                               'mail' => 'contact@example.com'
+                       ]
                ];
 
                //Here we define the parameters that are allowed to configure the bundle.
                ];
 
                //Here we define the parameters that are allowed to configure the bundle.
@@ -39,18 +47,30 @@ class Configuration implements ConfigurationInterface {
                        ->getRootNode()
                                ->addDefaultsIfNotSet()
                                ->children()
                        ->getRootNode()
                                ->addDefaultsIfNotSet()
                                ->children()
-                                       ->arrayNode('rapsys_air')
+                                       ->arrayNode('site')
                                                ->addDefaultsIfNotSet()
                                                ->children()
                                                ->addDefaultsIfNotSet()
                                                ->children()
-                                                       ->scalarNode('logo')->defaultValue($defaults['logo'])->treatNullLike($defaults['logo'])->isRequired()->end()
-                                                       ->scalarNode('title')->defaultValue($defaults['title'])->treatNullLike($defaults['title'])->isRequired()->end()
-                                                       ->scalarNode('contact_name')->defaultValue($defaults['contact_name'])->treatNullLike($defaults['contact_name'])->isRequired()->end()
-                                                       ->scalarNode('contact_mail')->defaultValue($defaults['contact_mail'])->treatNullLike($defaults['contact_mail'])->isRequired()->end()
+                                                       ->scalarNode('logo')->cannotBeEmpty()->defaultValue($defaults['site']['logo'])->end()
+                                                       ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['site']['title'])->end()
+                                               ->end()
+                                       ->end()
+                                       ->arrayNode('copy')
+                                               ->addDefaultsIfNotSet()
+                                               ->children()
+                                                       ->scalarNode('long')->defaultValue($defaults['copy']['long'])->end()
+                                                       ->scalarNode('short')->defaultValue($defaults['copy']['short'])->end()
+                                               ->end()
+                                       ->end()
+                                       ->arrayNode('contact')
+                                               ->addDefaultsIfNotSet()
+                                               ->children()
+                                                       ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['contact']['name'])->end()
+                                                       ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
                                                ->end()
                                        ->end()
                                ->end()
                        ->end();
 
                                                ->end()
                                        ->end()
                                ->end()
                        ->end();
 
-        return $treeBuilder;
-    }
+               return $treeBuilder;
+       }
 }
 }