]> Raphaƫl G. Git Repositories - airbundle/blob - DependencyInjection/Configuration.php
9b1c3a33c01f02b97e6a0d8d09c88f863347afc7
[airbundle] / DependencyInjection / Configuration.php
1 <?php
2
3 namespace Rapsys\AirBundle\DependencyInjection;
4
5 use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6 use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8 /**
9 * This is the class that validates and merges configuration from your app/config files.
10 *
11 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
12 */
13 class Configuration implements ConfigurationInterface {
14 /**
15 * {@inheritdoc}
16 */
17 public function getConfigTreeBuilder() {
18 $treeBuilder = new TreeBuilder('rapsys_air');
19
20 // Here you should define the parameters that are allowed to
21 // configure your bundle. See the documentation linked above for
22 // more information on that topic.
23 //Set defaults
24 $defaults = [
25 'site' => [
26 'logo' => '@RapsysAir/../public/png/logo.png',
27 'title' => 'Air Libre'
28 ],
29 'copy' => [
30 'long' => 'John Doe all rights reserved',
31 'short' => 'Copyright 2019'
32 ],
33 'contact' => [
34 'name' => 'John Doe',
35 'mail' => 'contact@example.com'
36 ]
37 ];
38
39 //Here we define the parameters that are allowed to configure the bundle.
40 //TODO: see https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php for default value and description
41 //TODO: see http://symfony.com/doc/current/components/config/definition.html
42 //XXX: use bin/console config:dump-reference to dump class infos
43
44 //Here we define the parameters that are allowed to configure the bundle.
45 $treeBuilder
46 //Parameters
47 ->getRootNode()
48 ->addDefaultsIfNotSet()
49 ->children()
50 ->arrayNode('site')
51 ->addDefaultsIfNotSet()
52 ->children()
53 ->scalarNode('logo')->cannotBeEmpty()->defaultValue($defaults['site']['logo'])->end()
54 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['site']['title'])->end()
55 ->end()
56 ->end()
57 ->arrayNode('copy')
58 ->addDefaultsIfNotSet()
59 ->children()
60 ->scalarNode('long')->defaultValue($defaults['copy']['long'])->end()
61 ->scalarNode('short')->defaultValue($defaults['copy']['short'])->end()
62 ->end()
63 ->end()
64 ->arrayNode('contact')
65 ->addDefaultsIfNotSet()
66 ->children()
67 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['contact']['name'])->end()
68 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
69 ->end()
70 ->end()
71 ->end()
72 ->end();
73
74 return $treeBuilder;
75 }
76 }