]> Raphaƫl G. Git Repositories - airbundle/blob - DependencyInjection/Configuration.php
New icon and logo layout in config
[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 use Rapsys\AirBundle\RapsysAirBundle;
9
10 /**
11 * This is the class that validates and merges configuration from your app/config files.
12 *
13 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
14 */
15 class Configuration implements ConfigurationInterface {
16 /**
17 * {@inheritdoc}
18 */
19 public function getConfigTreeBuilder() {
20 $treeBuilder = new TreeBuilder($alias = RapsysAirBundle::getAlias());
21
22 // Here you should define the parameters that are allowed to
23 // configure your bundle. See the documentation linked above for
24 // more information on that topic.
25 //Set defaults
26 $defaults = [
27 'site' => [
28 'donate' => 'https://paypal.me/milongaraphael',
29 'icon' => [
30 'ico' => '@RapsysAir/ico/icon.ico',
31 'svg' => '@RapsysAir/svg/icon.svg'
32 ],
33 'logo' => [
34 'png' => '@RapsysAir/png/logo.png',
35 'svg' => '@RapsysAir/svg/logo.svg'
36 ],
37 //The png icon array
38 //XXX: see https://www.emergeinteractive.com/insights/detail/the-essentials-of-favicons/
39 //XXX: see https://caniuse.com/#feat=link-icon-svg
40 'png' => [
41 //Default
42 256 => '@RapsysAir/png/icon.256.png',
43
44 //For google
45 //Chrome for Android home screen icon
46 196 => '@RapsysAir/png/icon.196.png',
47 //Google Developer Web App Manifest Recommendation
48 192 => '@RapsysAir/png/icon.192.png',
49 //Chrome Web Store icon
50 128 => '@RapsysAir/png/icon.128.png',
51
52 //Fallback
53 32 => '@RapsysAir/png/icon.32.png',
54
55 //For apple
56 //XXX: old obsolete format: [57, 72, 76, 114, 120, 144]
57 //XXX: see https://webhint.io/docs/user-guide/hints/hint-apple-touch-icons/
58 //XXX: see https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
59 //iPhone Retina
60 180 => '@RapsysAir/png/icon.180.png',
61 //iPad Retina touch icon
62 167 => '@RapsysAir/png/icon.167.png',
63 //iPad touch icon
64 152 => '@RapsysAir/png/icon.152.png',
65 //iOS7
66 120 => '@RapsysAir/png/icon.120.png',
67
68 //For windows
69 //XXX: see https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/dn255024(v=vs.85)
70 310 => '@RapsysAir/png/icon.310.png',
71 150 => '@RapsysAir/png/icon.150.png',
72 70 => '@RapsysAir/png/icon.70.png'
73 ],
74 'title' => 'Libre Air',
75 'url' => 'rapsys_air'
76 ],
77 'calendar' => [
78 'calendar' => '%env(string:RAPSYSAIR_CALENDAR)',
79 'prefix' => '%env(string:RAPSYSAIR_PREFIX)',
80 'project' => '%env(string:RAPSYSAIR_PROJECT)',
81 'client' => '%env(string:GOOGLE_CLIENT_ID)',
82 'secret' => '%env(string:GOOGLE_CLIENT_SECRET)'
83 ],
84 'copy' => [
85 'by' => 'Rapsys',
86 'link' => 'https://rapsys.eu',
87 'long' => 'All rights reserved',
88 'short' => 'Copyright 2019-2021',
89 'title' => 'Rapsys'
90 ],
91 'contact' => [
92 'title' => 'Libre Air',
93 'mail' => 'contact@airlibre.eu'
94 ],
95 'facebook' => [
96 'apps' => [3728770287223690],
97 'height' => 630,
98 'width' => 1200
99 ],
100 'locale' => '%kernel.default_locale%',
101 'locales' => '%kernel.translator.fallbacks%',
102 //XXX: revert to underscore because of that shit:
103 //XXX: see https://symfony.com/doc/current/components/config/definition.html#normalization
104 //XXX: see https://github.com/symfony/symfony/issues/7405
105 'languages' => '%rapsys_user.languages%',
106 'path' => is_link(($prefix = is_dir('public') ? './public/' : './').($link = 'bundles/'.str_replace('_', '', $alias))) && is_dir(realpath($prefix.$link)) || is_dir($prefix.$link) ? $link : dirname(__DIR__).'/Resources/public'
107 #'public' => [
108 # //XXX: get path with bundles/<alias> or full path if not installed
109 # //XXX: current working directory may be project dir or public subdir depending on context
110 # 'path' => is_link(($prefix = is_dir('public') ? './public/' : './').($link = 'bundles/'.str_replace('_', '', $alias))) && is_dir(realpath($prefix.$link)) || is_dir($prefix.$link) ? $link : dirname(__DIR__).'/Resources/public',
111 # 'url' => '/bundles/'.str_replace('_', '', $alias)
112 #]
113 ];
114
115 //Here we define the parameters that are allowed to configure the bundle.
116 //TODO: see https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php for default value and description
117 //TODO: see http://symfony.com/doc/current/components/config/definition.html
118 //XXX: use bin/console config:dump-reference to dump class infos
119
120 //Here we define the parameters that are allowed to configure the bundle.
121 $treeBuilder
122 //Parameters
123 ->getRootNode()
124 ->addDefaultsIfNotSet()
125 ->children()
126 ->arrayNode('site')
127 ->addDefaultsIfNotSet()
128 ->children()
129 ->scalarNode('donate')->cannotBeEmpty()->defaultValue($defaults['site']['donate'])->end()
130 ->arrayNode('icon')
131 ->treatNullLike([])
132 ->defaultValue($defaults['site']['icon'])
133 ->scalarPrototype()->end()
134 ->end()
135 ->arrayNode('logo')
136 ->treatNullLike([])
137 ->defaultValue($defaults['site']['logo'])
138 ->scalarPrototype()->end()
139 ->end()
140 ->arrayNode('png')
141 ->treatNullLike([])
142 ->defaultValue($defaults['site']['png'])
143 ->scalarPrototype()->end()
144 ->end()
145 /*->scalarNode('ico')->cannotBeEmpty()->defaultValue($defaults['site']['ico'])->end()
146 ->scalarNode('logo')->cannotBeEmpty()->defaultValue($defaults['site']['logo'])->end()
147 ->scalarNode('svg')->cannotBeEmpty()->defaultValue($defaults['site']['svg'])->end()*/
148 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['site']['title'])->end()
149 ->scalarNode('url')->cannotBeEmpty()->defaultValue($defaults['site']['url'])->end()
150 ->end()
151 ->end()
152 ->arrayNode('calendar')
153 ->addDefaultsIfNotSet()
154 ->children()
155 ->scalarNode('calendar')->defaultValue($defaults['calendar']['calendar'])->end()
156 ->scalarNode('prefix')->defaultValue($defaults['calendar']['prefix'])->end()
157 ->scalarNode('project')->defaultValue($defaults['calendar']['project'])->end()
158 ->scalarNode('client')->defaultValue($defaults['calendar']['client'])->end()
159 ->scalarNode('secret')->defaultValue($defaults['calendar']['secret'])->end()
160 ->end()
161 ->end()
162 ->arrayNode('copy')
163 ->addDefaultsIfNotSet()
164 ->children()
165 ->scalarNode('by')->defaultValue($defaults['copy']['by'])->end()
166 ->scalarNode('link')->defaultValue($defaults['copy']['link'])->end()
167 ->scalarNode('long')->defaultValue($defaults['copy']['long'])->end()
168 ->scalarNode('short')->defaultValue($defaults['copy']['short'])->end()
169 ->scalarNode('title')->defaultValue($defaults['copy']['title'])->end()
170 ->end()
171 ->end()
172 ->arrayNode('contact')
173 ->addDefaultsIfNotSet()
174 ->children()
175 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['contact']['title'])->end()
176 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
177 ->end()
178 ->end()
179 ->arrayNode('facebook')
180 ->addDefaultsIfNotSet()
181 ->children()
182 ->arrayNode('apps')
183 ->treatNullLike([])
184 ->defaultValue($defaults['facebook']['apps'])
185 ->scalarPrototype()->end()
186 ->end()
187 ->integerNode('height')->min(0)->defaultValue($defaults['facebook']['height'])->end()
188 ->integerNode('width')->min(0)->defaultValue($defaults['facebook']['width'])->end()
189 ->end()
190 ->end()
191 ->scalarNode('locale')->cannotBeEmpty()->defaultValue($defaults['locale'])->end()
192 #TODO: see if we can't prevent key normalisation with ->normalizeKeys(false)
193 #->scalarNode('locales')->cannotBeEmpty()->defaultValue($defaults['locales'])->end()
194 ->variableNode('locales')
195 ->treatNullLike([])
196 ->defaultValue($defaults['locales'])
197 #->scalarPrototype()->end()
198 ->end()
199 #TODO: see if we can't prevent key normalisation with ->normalizeKeys(false)
200 #->scalarNode('languages')->cannotBeEmpty()->defaultValue($defaults['languages'])->end()
201 ->variableNode('languages')
202 ->treatNullLike([])
203 ->defaultValue($defaults['languages'])
204 #->scalarPrototype()->end()
205 ->end()
206 ->scalarNode('path')->defaultValue($defaults['path'])->end()
207 #->arrayNode('public')
208 # ->addDefaultsIfNotSet()
209 # ->children()
210 # ->scalarNode('path')->defaultValue($defaults['public']['path'])->end()
211 # ->scalarNode('url')->defaultValue($defaults['public']['url'])->end()
212 # ->end()
213 #->end()
214 ->end()
215 ->end();
216
217 return $treeBuilder;
218 }
219 }