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 Symfony\Component\Config\Definition\Builder\TreeBuilder
;
15 use Symfony\Component\Config\Definition\ConfigurationInterface
;
16 use Symfony\Component\DependencyInjection\Container
;
17 use Symfony\Component\Process\ExecutableFinder
;
19 use Rapsys\PackBundle\RapsysPackBundle
;
22 * This is the class that validates and merges configuration from your app/config files.
24 * @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
44 'class' => 'Rapsys\PackBundle\Filter\CPackFilter',
46 $finder->find('cpack', '/usr/local/bin/cpack'),
53 'class' => 'Rapsys\PackBundle\Filter\IPackFilter',
59 'class' => 'Rapsys\PackBundle\Filter\JPackFilter',
61 $finder->find('jpack', '/usr/local/bin/jpack'),
67 #TODO: migrate to public.path, public.url and router->generateUrl ?
68 #XXX: that would means dropping the PathPackage stuff and use static route like rapsyspack_facebook
70 'css' => '@RapsysPack/css/*.pack.css',
71 'img' => '@RapsysPack/img/*.pack.jpg',
72 'js' => '@RapsysPack/js/*.pack.js'
74 'path' => dirname(__DIR__
).'/Resources/public',
75 'token' => 'asset_url'
79 * Defines parameters allowed to configure the bundle
81 * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
82 * @link http://symfony.com/doc/current/components/config/definition.html
83 * @link https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
85 * @see php bin/console config:dump-reference rapsyspack to dump default config
86 * @see php bin/console debug:config rapsyspack to dump config
91 ->addDefaultsIfNotSet()
93 ->arrayNode('filters')
94 ->addDefaultsIfNotSet()
100 * @see Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +513
102 ->addDefaultChildrenIfNoneSet()
105 ->scalarNode('class')
108 ->defaultValue($defaults['filters']['css'][0]['class'])
113 ->defaultValue($defaults['filters']['css'][0]['args'])
114 ->scalarPrototype()->end()
123 * @see Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +513
125 ->addDefaultChildrenIfNoneSet()
128 ->scalarNode('class')
131 ->defaultValue($defaults['filters']['img'][0]['class'])
135 ->defaultValue($defaults['filters']['img'][0]['args'])
136 ->scalarPrototype()->end()
145 * @see Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +513
147 ->addDefaultChildrenIfNoneSet()
150 ->scalarNode('class')
153 ->defaultValue($defaults['filters']['js'][0]['class'])
157 ->defaultValue($defaults['filters']['js'][0]['args'])
158 ->scalarPrototype()->end()
165 ->arrayNode('output')
166 ->addDefaultsIfNotSet()
168 ->scalarNode('css')->cannotBeEmpty()->defaultValue($defaults['output']['css'])->end()
169 ->scalarNode('img')->cannotBeEmpty()->defaultValue($defaults['output']['img'])->end()
170 ->scalarNode('js')->cannotBeEmpty()->defaultValue($defaults['output']['js'])->end()
173 ->scalarNode('path')->cannotBeEmpty()->defaultValue($defaults['path'])->end()
174 ->scalarNode('token')->cannotBeEmpty()->defaultValue($defaults['token'])->end()