1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys PackBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\PackBundle\DependencyInjection
;
14 use Rapsys\PackBundle\RapsysPackBundle
;
16 use Symfony\Component\Config\Definition\Builder\TreeBuilder
;
17 use Symfony\Component\Config\Definition\ConfigurationInterface
;
18 use Symfony\Component\DependencyInjection\Container
;
19 use Symfony\Component\Process\ExecutableFinder
;
24 * This is the class that validates and merges configuration from your app/config files.
26 * @link http://symfony.com/doc/current/cookbook/bundles/configuration.html
28 class Configuration
implements ConfigurationInterface
{
32 public function getConfigTreeBuilder(): TreeBuilder
{
33 //Get TreeBuilder object
34 $treeBuilder = new TreeBuilder($alias = RapsysPackBundle
::getAlias());
36 //Get ExecutableFinder object
37 $finder = new ExecutableFinder();
39 //The bundle default values
41 //XXX: use a path relative to __DIR__ as console and index do not have the same execution directory
42 //XXX: use realpath on var/cache only as alias subdirectory may not yet exists
43 'cache' => realpath(dirname(__DIR__
).'/../../../var/cache').'/'.$alias,
45 'background' => 'white',
49 'border' => '#00c3f9',
59 'source' => dirname(__DIR__
).'/public/facebook/source.png',
60 'border' => '#00c3f9',
67 'class' => 'Rapsys\PackBundle\Filter\CPackFilter',
69 $finder->find('cpack', '/usr/local/bin/cpack'),
76 'class' => 'Rapsys\PackBundle\Filter\IPackFilter',
82 'class' => 'Rapsys\PackBundle\Filter\JPackFilter',
84 $finder->find('jpack', '/usr/local/bin/jpack'),
91 'default' => '/usr/share/fonts/TTF/dejavu/DejaVuSans.ttf',
92 #TODO: move these in veranda config ? with *: %rapsyspack.public%/woff2/*.woff2 ?
93 'droidsans' => dirname(__DIR__
).'/public/woff2/droidsans.regular.woff2',
94 'droidsansb' => dirname(__DIR__
).'/public/woff2/droidsans.bold.woff2',
95 'droidsansi' => dirname(__DIR__
).'/public/woff2/droidserif.italic.woff2',
96 'droidsansm' => dirname(__DIR__
).'/public/woff2/droidsansmono.regular.woff2',
97 'droidserif' => dirname(__DIR__
).'/public/woff2/droidserif.regular.woff2',
98 'droidserifb' => dirname(__DIR__
).'/public/woff2/droidserif.bold.woff2',
99 'droidserifbi' => dirname(__DIR__
).'/public/woff2/droidserif.bolditalic.woff2',
100 'irishgrover' => dirname(__DIR__
).'/public/woff2/irishgrover.v10.woff2',
101 'lemon' => dirname(__DIR__
).'/public/woff2/lemon.woff2',
102 'notoemoji' => dirname(__DIR__
).'/public/woff2/notoemoji.woff2'
105 'border' => '#00c3f9',
117 'border' => '#00c3f9',
120 'highborder' => '#3333c3',
121 'highfill' => '#c3c3f9',
124 'highthickness' => 4,
135 'captcha' => 'captcha',
137 'facebook' => 'facebook',
145 //XXX: use a path relative to __DIR__ as console and index do not have the same execution directory
146 'public' => dirname(__DIR__
).'/public',
148 'css' => 'rapsyspack_css',
149 'img' => 'rapsyspack_img',
150 'js' => 'rapsyspack_js'
153 'cycle' => 'http://a.tile.thunderforest.com/cycle/{Z}/{X}/{Y}.png',
154 'osm' => 'https://tile.openstreetmap.org/{Z}/{X}/{Y}.png',
155 'transport' => 'http://a.tile.thunderforest.com/transport/{Z}/{X}/{Y}.png'
169 * Defines parameters allowed to configure the bundle
171 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
172 * @link http://symfony.com/doc/current/components/config/definition.html
173 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
175 * @see bin/console config:dump-reference rapsyspack to dump default config
176 * @see bin/console debug:config rapsyspack to dump config
181 ->addDefaultsIfNotSet()
183 ->scalarNode('cache')->cannotBeEmpty()->defaultValue($defaults['cache'])->end()
184 ->arrayNode('captcha')
185 ->addDefaultsIfNotSet()
187 ->scalarNode('background')->cannotBeEmpty()->defaultValue($defaults['captcha']['background'])->end()
188 ->scalarNode('fill')->cannotBeEmpty()->defaultValue($defaults['captcha']['fill'])->end()
189 ->scalarNode('height')->cannotBeEmpty()->defaultValue($defaults['captcha']['height'])->end()
190 ->scalarNode('size')->cannotBeEmpty()->defaultValue($defaults['captcha']['size'])->end()
191 ->scalarNode('border')->cannotBeEmpty()->defaultValue($defaults['captcha']['border'])->end()
192 ->scalarNode('thickness')->cannotBeEmpty()->defaultValue($defaults['captcha']['thickness'])->end()
193 ->scalarNode('width')->cannotBeEmpty()->defaultValue($defaults['captcha']['width'])->end()
196 ->arrayNode('facebook')
197 ->addDefaultsIfNotSet()
199 ->scalarNode('align')->cannotBeEmpty()->defaultValue($defaults['facebook']['align'])->end()
200 ->scalarNode('fill')->cannotBeEmpty()->defaultValue($defaults['facebook']['fill'])->end()
201 ->scalarNode('font')->cannotBeEmpty()->defaultValue($defaults['facebook']['font'])->end()
202 ->scalarNode('height')->cannotBeEmpty()->defaultValue($defaults['facebook']['height'])->end()
203 ->scalarNode('size')->cannotBeEmpty()->defaultValue($defaults['facebook']['size'])->end()
204 ->scalarNode('source')->cannotBeEmpty()->defaultValue($defaults['facebook']['source'])->end()
205 ->scalarNode('border')->cannotBeEmpty()->defaultValue($defaults['facebook']['border'])->end()
206 ->scalarNode('thickness')->cannotBeEmpty()->defaultValue($defaults['facebook']['thickness'])->end()
207 ->scalarNode('width')->cannotBeEmpty()->defaultValue($defaults['facebook']['width'])->end()
210 ->arrayNode('filters')
211 ->addDefaultsIfNotSet()
217 * @see Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +513
219 ->addDefaultChildrenIfNoneSet()
222 ->scalarNode('class')
225 ->defaultValue($defaults['filters']['css'][0]['class'])
230 ->defaultValue($defaults['filters']['css'][0]['args'])
231 ->scalarPrototype()->end()
240 * @see Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +513
242 ->addDefaultChildrenIfNoneSet()
245 ->scalarNode('class')
248 ->defaultValue($defaults['filters']['img'][0]['class'])
252 ->defaultValue($defaults['filters']['img'][0]['args'])
253 ->scalarPrototype()->end()
262 * @see Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +513
264 ->addDefaultChildrenIfNoneSet()
267 ->scalarNode('class')
270 ->defaultValue($defaults['filters']['js'][0]['class'])
274 ->defaultValue($defaults['filters']['js'][0]['args'])
275 ->scalarPrototype()->end()
284 ->defaultValue($defaults['fonts'])
285 ->scalarPrototype()->end()
288 ->addDefaultsIfNotSet()
290 ->scalarNode('border')->cannotBeEmpty()->defaultValue($defaults['map']['border'])->end()
291 ->scalarNode('fill')->cannotBeEmpty()->defaultValue($defaults['map']['fill'])->end()
292 ->scalarNode('height')->cannotBeEmpty()->defaultValue($defaults['map']['height'])->end()
293 ->scalarNode('quality')->cannotBeEmpty()->defaultValue($defaults['map']['quality'])->end()
294 ->scalarNode('radius')->cannotBeEmpty()->defaultValue($defaults['map']['radius'])->end()
295 ->scalarNode('server')->cannotBeEmpty()->defaultValue($defaults['map']['server'])->end()
296 ->scalarNode('thickness')->cannotBeEmpty()->defaultValue($defaults['map']['thickness'])->end()
297 ->scalarNode('tz')->cannotBeEmpty()->defaultValue($defaults['map']['tz'])->end()
298 ->scalarNode('width')->cannotBeEmpty()->defaultValue($defaults['map']['width'])->end()
299 ->scalarNode('zoom')->cannotBeEmpty()->defaultValue($defaults['map']['zoom'])->end()
303 ->addDefaultsIfNotSet()
305 ->scalarNode('border')->cannotBeEmpty()->defaultValue($defaults['multi']['border'])->end()
306 ->scalarNode('fill')->cannotBeEmpty()->defaultValue($defaults['multi']['fill'])->end()
307 ->scalarNode('height')->cannotBeEmpty()->defaultValue($defaults['multi']['height'])->end()
308 ->scalarNode('highborder')->cannotBeEmpty()->defaultValue($defaults['multi']['highborder'])->end()
309 ->scalarNode('highfill')->cannotBeEmpty()->defaultValue($defaults['multi']['highfill'])->end()
310 ->scalarNode('highradius')->cannotBeEmpty()->defaultValue($defaults['multi']['highradius'])->end()
311 ->scalarNode('highsize')->cannotBeEmpty()->defaultValue($defaults['multi']['highsize'])->end()
312 ->scalarNode('highthickness')->cannotBeEmpty()->defaultValue($defaults['multi']['highthickness'])->end()
313 ->scalarNode('quality')->cannotBeEmpty()->defaultValue($defaults['multi']['quality'])->end()
314 ->scalarNode('radius')->cannotBeEmpty()->defaultValue($defaults['multi']['radius'])->end()
315 ->scalarNode('server')->cannotBeEmpty()->defaultValue($defaults['multi']['server'])->end()
316 ->scalarNode('size')->cannotBeEmpty()->defaultValue($defaults['multi']['size'])->end()
317 ->scalarNode('thickness')->cannotBeEmpty()->defaultValue($defaults['multi']['thickness'])->end()
318 ->scalarNode('tz')->cannotBeEmpty()->defaultValue($defaults['multi']['tz'])->end()
319 ->scalarNode('width')->cannotBeEmpty()->defaultValue($defaults['multi']['width'])->end()
320 ->scalarNode('zoom')->cannotBeEmpty()->defaultValue($defaults['multi']['zoom'])->end()
323 ->arrayNode('prefixes')
325 ->defaultValue($defaults['prefixes'])
326 ->scalarPrototype()->end()
328 ->scalarNode('public')->cannotBeEmpty()->defaultValue($defaults['public'])->end()
329 ->arrayNode('routes')
330 ->addDefaultsIfNotSet()
332 ->scalarNode('css')->cannotBeEmpty()->defaultValue($defaults['routes']['css'])->end()
333 ->scalarNode('img')->cannotBeEmpty()->defaultValue($defaults['routes']['img'])->end()
334 ->scalarNode('js')->cannotBeEmpty()->defaultValue($defaults['routes']['js'])->end()
337 ->arrayNode('servers')
339 ->defaultValue($defaults['servers'])
340 ->scalarPrototype()->end()
343 ->addDefaultsIfNotSet()
345 ->scalarNode('height')->cannotBeEmpty()->defaultValue($defaults['thumb']['height'])->end()
346 ->scalarNode('width')->cannotBeEmpty()->defaultValue($defaults['thumb']['width'])->end()
349 ->arrayNode('tokens')
350 ->addDefaultsIfNotSet()
352 ->scalarNode('css')->cannotBeEmpty()->defaultValue($defaults['tokens']['css'])->end()
353 ->scalarNode('img')->cannotBeEmpty()->defaultValue($defaults['tokens']['img'])->end()
354 ->scalarNode('js')->cannotBeEmpty()->defaultValue($defaults['tokens']['js'])->end()