]> Raphaƫl G. Git Repositories - airbundle/blob - DependencyInjection/Configuration.php
131ca1b5884a8b4c81b0efb592f286be58009f43
[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 'donate' => 'https://paypal.me/milongaraphael',
27 'ico' => '@RapsysAir/ico/icon.ico',
28 'logo' => '@RapsysAir/png/logo.png',
29 //The png icon array
30 //XXX: see https://www.emergeinteractive.com/insights/detail/the-essentials-of-favicons/
31 //XXX: see https://caniuse.com/#feat=link-icon-svg
32 'png' => [
33 //Default
34 256 => '@RapsysAir/png/icon.256.png',
35
36 //For google
37 //Chrome for Android home screen icon
38 196 => '@RapsysAir/png/icon.196.png',
39 //Google Developer Web App Manifest Recommendation
40 192 => '@RapsysAir/png/icon.192.png',
41 //Chrome Web Store icon
42 128 => '@RapsysAir/png/icon.128.png',
43
44 //Fallback
45 32 => '@RapsysAir/png/icon.32.png',
46
47 //For apple
48 //XXX: old obsolete format: [57, 72, 76, 114, 120, 144]
49 //XXX: see https://webhint.io/docs/user-guide/hints/hint-apple-touch-icons/
50 //XXX: see https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
51 //iPhone Retina
52 180 => '@RapsysAir/png/icon.180.png',
53 //iPad Retina touch icon
54 167 => '@RapsysAir/png/icon.167.png',
55 //iPad touch icon
56 152 => '@RapsysAir/png/icon.152.png',
57 //iOS7
58 120 => '@RapsysAir/png/icon.120.png',
59
60 //For windows
61 //XXX: see https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/dn255024(v=vs.85)
62 310 => '@RapsysAir/png/icon.310.png',
63 150 => '@RapsysAir/png/icon.150.png',
64 70 => '@RapsysAir/png/icon.70.png'
65 ],
66 'svg' => '@RapsysAir/svg/icon.svg',
67 'title' => 'Libre Air',
68 'url' => 'rapsys_air'
69 ],
70 'cache' => [
71 'namespace' => 'airlibre',
72 'lifetime' => 0
73 ],
74 'calendar' => [
75 'calendar' => '%env(string:RAPSYSAIR_CALENDAR)',
76 'prefix' => '%env(string:RAPSYSAIR_PREFIX)',
77 'project' => '%env(string:RAPSYSAIR_PROJECT)',
78 'client' => '%env(string:GOOGLE_CLIENT_ID)',
79 'secret' => '%env(string:GOOGLE_CLIENT_SECRET)'
80 ],
81 'copy' => [
82 'by' => 'Rapsys',
83 'link' => 'https://rapsys.eu',
84 'long' => 'All rights reserved',
85 'short' => 'Copyright 2019-2021',
86 'title' => 'Rapsys'
87 ],
88 'contact' => [
89 'title' => 'Libre Air',
90 'mail' => 'contact@airlibre.eu'
91 ],
92 'facebook' => [
93 'apps' => [3728770287223690],
94 'height' => 630,
95 'width' => 1200
96 ],
97 'locale' => '%kernel.default_locale%',
98 'locales' => '%kernel.translator.fallbacks%',
99 'languages' => '%rapsys_user.languages%',
100 'path' => [
101 'cache' => '%kernel.project_dir%/var/cache',
102 'public' => dirname(__DIR__).'/Resources/public'
103 ]
104 ];
105
106 //Here we define the parameters that are allowed to configure the bundle.
107 //TODO: see https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php for default value and description
108 //TODO: see http://symfony.com/doc/current/components/config/definition.html
109 //XXX: use bin/console config:dump-reference to dump class infos
110
111 //Here we define the parameters that are allowed to configure the bundle.
112 $treeBuilder
113 //Parameters
114 ->getRootNode()
115 ->addDefaultsIfNotSet()
116 ->children()
117 ->arrayNode('site')
118 ->addDefaultsIfNotSet()
119 ->children()
120 ->scalarNode('donate')->cannotBeEmpty()->defaultValue($defaults['site']['donate'])->end()
121 ->scalarNode('ico')->cannotBeEmpty()->defaultValue($defaults['site']['ico'])->end()
122 ->scalarNode('logo')->cannotBeEmpty()->defaultValue($defaults['site']['logo'])->end()
123 ->arrayNode('png')
124 ->treatNullLike([])
125 ->defaultValue($defaults['site']['png'])
126 ->scalarPrototype()->end()
127 ->end()
128 ->scalarNode('svg')->cannotBeEmpty()->defaultValue($defaults['site']['svg'])->end()
129 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['site']['title'])->end()
130 ->scalarNode('url')->cannotBeEmpty()->defaultValue($defaults['site']['url'])->end()
131 ->end()
132 ->end()
133 ->arrayNode('cache')
134 ->addDefaultsIfNotSet()
135 ->children()
136 ->scalarNode('namespace')->defaultValue($defaults['cache']['namespace'])->end()
137 ->integerNode('lifetime')->min(0)->defaultValue($defaults['cache']['lifetime'])->end()
138 ->end()
139 ->end()
140 ->arrayNode('calendar')
141 ->addDefaultsIfNotSet()
142 ->children()
143 ->scalarNode('calendar')->defaultValue($defaults['calendar']['calendar'])->end()
144 ->scalarNode('prefix')->defaultValue($defaults['calendar']['prefix'])->end()
145 ->scalarNode('project')->defaultValue($defaults['calendar']['project'])->end()
146 ->scalarNode('client')->defaultValue($defaults['calendar']['client'])->end()
147 ->scalarNode('secret')->defaultValue($defaults['calendar']['secret'])->end()
148 ->end()
149 ->end()
150 ->arrayNode('copy')
151 ->addDefaultsIfNotSet()
152 ->children()
153 ->scalarNode('by')->defaultValue($defaults['copy']['by'])->end()
154 ->scalarNode('link')->defaultValue($defaults['copy']['link'])->end()
155 ->scalarNode('long')->defaultValue($defaults['copy']['long'])->end()
156 ->scalarNode('short')->defaultValue($defaults['copy']['short'])->end()
157 ->scalarNode('title')->defaultValue($defaults['copy']['title'])->end()
158 ->end()
159 ->end()
160 ->arrayNode('contact')
161 ->addDefaultsIfNotSet()
162 ->children()
163 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['contact']['title'])->end()
164 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
165 ->end()
166 ->end()
167 ->arrayNode('facebook')
168 ->addDefaultsIfNotSet()
169 ->children()
170 ->arrayNode('apps')
171 ->treatNullLike([])
172 ->defaultValue($defaults['facebook']['apps'])
173 ->scalarPrototype()->end()
174 ->end()
175 ->integerNode('height')->min(0)->defaultValue($defaults['facebook']['height'])->end()
176 ->integerNode('width')->min(0)->defaultValue($defaults['facebook']['width'])->end()
177 ->end()
178 ->end()
179 ->scalarNode('locale')->cannotBeEmpty()->defaultValue($defaults['locale'])->end()
180 ->scalarNode('locales')->cannotBeEmpty()->defaultValue($defaults['locales'])->end()
181 ->scalarNode('languages')->cannotBeEmpty()->defaultValue($defaults['languages'])->end()
182 ->arrayNode('path')
183 ->addDefaultsIfNotSet()
184 ->children()
185 ->scalarNode('cache')->defaultValue($defaults['path']['cache'])->end()
186 ->scalarNode('public')->defaultValue($defaults['path']['public'])->end()
187 ->end()
188 ->end()
189 ->end()
190 ->end();
191
192 return $treeBuilder;
193 }
194 }