]> Raphaƫl G. Git Repositories - airbundle/blob - DependencyInjection/Configuration.php
Update controller base class name
[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 'google' => [
78 'client' => '%env(string:GOOGLE_CLIENT)',
79 'project' => '%env(string:GOOGLE_PROJECT)',
80 'secret' => '%env(string:GOOGLE_SECRET)'
81 ],
82 'copy' => [
83 'by' => 'Rapsys',
84 'link' => 'https://rapsys.eu',
85 'long' => 'All rights reserved',
86 'short' => 'Copyright 2019-2021',
87 'title' => 'Rapsys'
88 ],
89 'contact' => [
90 'title' => 'Libre Air',
91 'mail' => 'contact@airlibre.eu'
92 ],
93 'facebook' => [
94 'apps' => [3728770287223690],
95 'height' => 630,
96 'width' => 1200
97 ],
98 'locale' => '%kernel.default_locale%',
99 'locales' => '%kernel.translator.fallbacks%',
100 //XXX: revert to underscore because of that shit:
101 //XXX: see https://symfony.com/doc/current/components/config/definition.html#normalization
102 //XXX: see https://github.com/symfony/symfony/issues/7405
103 'languages' => '%rapsys_user.languages%',
104 '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'
105 #'public' => [
106 # //XXX: get path with bundles/<alias> or full path if not installed
107 # //XXX: current working directory may be project dir or public subdir depending on context
108 # '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',
109 # 'url' => '/bundles/'.str_replace('_', '', $alias)
110 #]
111 ];
112
113 //Here we define the parameters that are allowed to configure the bundle.
114 //TODO: see https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php for default value and description
115 //TODO: see http://symfony.com/doc/current/components/config/definition.html
116 //XXX: use bin/console config:dump-reference to dump class infos
117
118 //Here we define the parameters that are allowed to configure the bundle.
119 $treeBuilder
120 //Parameters
121 ->getRootNode()
122 ->addDefaultsIfNotSet()
123 ->children()
124 ->arrayNode('site')
125 ->addDefaultsIfNotSet()
126 ->children()
127 ->scalarNode('donate')->cannotBeEmpty()->defaultValue($defaults['site']['donate'])->end()
128 ->arrayNode('icon')
129 ->treatNullLike([])
130 ->defaultValue($defaults['site']['icon'])
131 ->scalarPrototype()->end()
132 ->end()
133 ->arrayNode('logo')
134 ->treatNullLike([])
135 ->defaultValue($defaults['site']['logo'])
136 ->scalarPrototype()->end()
137 ->end()
138 ->arrayNode('png')
139 ->treatNullLike([])
140 ->defaultValue($defaults['site']['png'])
141 ->scalarPrototype()->end()
142 ->end()
143 /*->scalarNode('ico')->cannotBeEmpty()->defaultValue($defaults['site']['ico'])->end()
144 ->scalarNode('logo')->cannotBeEmpty()->defaultValue($defaults['site']['logo'])->end()
145 ->scalarNode('svg')->cannotBeEmpty()->defaultValue($defaults['site']['svg'])->end()*/
146 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['site']['title'])->end()
147 ->scalarNode('url')->cannotBeEmpty()->defaultValue($defaults['site']['url'])->end()
148 ->end()
149 ->end()
150 ->arrayNode('google')
151 ->addDefaultsIfNotSet()
152 ->children()
153 ->scalarNode('client')->defaultValue($defaults['google']['client'])->end()
154 ->scalarNode('project')->defaultValue($defaults['google']['project'])->end()
155 ->scalarNode('secret')->defaultValue($defaults['google']['secret'])->end()
156 ->end()
157 ->end()
158 ->arrayNode('copy')
159 ->addDefaultsIfNotSet()
160 ->children()
161 ->scalarNode('by')->defaultValue($defaults['copy']['by'])->end()
162 ->scalarNode('link')->defaultValue($defaults['copy']['link'])->end()
163 ->scalarNode('long')->defaultValue($defaults['copy']['long'])->end()
164 ->scalarNode('short')->defaultValue($defaults['copy']['short'])->end()
165 ->scalarNode('title')->defaultValue($defaults['copy']['title'])->end()
166 ->end()
167 ->end()
168 ->arrayNode('contact')
169 ->addDefaultsIfNotSet()
170 ->children()
171 ->scalarNode('title')->cannotBeEmpty()->defaultValue($defaults['contact']['title'])->end()
172 ->scalarNode('mail')->cannotBeEmpty()->defaultValue($defaults['contact']['mail'])->end()
173 ->end()
174 ->end()
175 ->arrayNode('facebook')
176 ->addDefaultsIfNotSet()
177 ->children()
178 ->arrayNode('apps')
179 ->treatNullLike([])
180 ->defaultValue($defaults['facebook']['apps'])
181 ->scalarPrototype()->end()
182 ->end()
183 ->integerNode('height')->min(0)->defaultValue($defaults['facebook']['height'])->end()
184 ->integerNode('width')->min(0)->defaultValue($defaults['facebook']['width'])->end()
185 ->end()
186 ->end()
187 ->scalarNode('locale')->cannotBeEmpty()->defaultValue($defaults['locale'])->end()
188 #TODO: see if we can't prevent key normalisation with ->normalizeKeys(false)
189 #->scalarNode('locales')->cannotBeEmpty()->defaultValue($defaults['locales'])->end()
190 ->variableNode('locales')
191 ->treatNullLike([])
192 ->defaultValue($defaults['locales'])
193 #->scalarPrototype()->end()
194 ->end()
195 #TODO: see if we can't prevent key normalisation with ->normalizeKeys(false)
196 #->scalarNode('languages')->cannotBeEmpty()->defaultValue($defaults['languages'])->end()
197 ->variableNode('languages')
198 ->treatNullLike([])
199 ->defaultValue($defaults['languages'])
200 #->scalarPrototype()->end()
201 ->end()
202 ->scalarNode('path')->defaultValue($defaults['path'])->end()
203 #->arrayNode('public')
204 # ->addDefaultsIfNotSet()
205 # ->children()
206 # ->scalarNode('path')->defaultValue($defaults['public']['path'])->end()
207 # ->scalarNode('url')->defaultValue($defaults['public']['url'])->end()
208 # ->end()
209 #->end()
210 ->end()
211 ->end();
212
213 return $treeBuilder;
214 }
215 }