3 namespace Rapsys\PackBundle\DependencyInjection
;
5 use Symfony\Component\Config\Definition\Builder\TreeBuilder
;
6 use Symfony\Component\Config\Definition\ConfigurationInterface
;
7 use Symfony\Component\Process\ExecutableFinder
;
10 * This is the class that validates and merges configuration from your app/config files.
12 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
14 class Configuration
implements ConfigurationInterface
{
18 public function getConfigTreeBuilder() {
19 //Get TreeBuilder object
20 $treeBuilder = new TreeBuilder('rapsys_pack');
22 //Get ExecutableFinder object
23 $finder = new ExecutableFinder();
26 * XXX: Note about the output schemes
28 * The output files are written based on the output.<ext> scheme with the * replaced by the hashed path of packed files
30 * The following service configuration make twig render the output file path with the right '/' basePath prefix:
32 * assets.pack_package:
33 * class: Rapsys\PackBundle\Asset\PathPackage
34 * arguments: [ '/', '@assets.empty_version_strategy', '@assets.context' ]
35 * rapsys_pack.twig.pack_extension:
36 * class: Rapsys\PackBundle\Twig\PackExtension
37 * arguments: [ '@file_locator', '@service_container', '@assets.pack_package' ]
38 * tags: [ twig.extension ]
41 //The bundle default values
44 'name' => 'asset_url',
45 'scheme' => 'https://',
46 'timeout' => (int)ini_get('default_socket_timeout'),
47 'agent' => (string)ini_get('user_agent')?:'rapsys_pack/0.1.3',
51 'css' => '@RapsysPack/css/*.pack.css',
52 'js' => '@RapsysPack/js/*.pack.js',
53 'img' => '@RapsysPack/img/*.pack.jpg'
57 'class' => 'Rapsys\PackBundle\Twig\Filter\CPackFilter',
59 $finder->find('cpack', '/usr/local/bin/cpack'),
64 'class' => 'Rapsys\PackBundle\Twig\Filter\JPackFilter',
66 $finder->find('jpack', '/usr/local/bin/jpack'),
71 'class' => 'Rapsys\PackBundle\Twig\Filter\IPackFilter',
77 //Here we define the parameters that are allowed to configure the bundle.
78 //XXX: see https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php for default value and description
79 //XXX: see http://symfony.com/doc/current/components/config/definition.html
80 //XXX: see https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
81 //XXX: see php bin/console config:dump-reference rapsys_pack to dump default config
82 //XXX: see php bin/console debug:config rapsys_pack to dump config
86 ->addDefaultsIfNotSet()
89 ->addDefaultsIfNotSet()
91 ->scalarNode('name')->cannotBeEmpty()->defaultValue($defaults['config']['name'])->end()
92 ->scalarNode('scheme')->cannotBeEmpty()->defaultValue($defaults['config']['scheme'])->end()
93 ->integerNode('timeout')->min(0)->max(300)->defaultValue($defaults['config']['timeout'])->end()
94 ->scalarNode('agent')->cannotBeEmpty()->defaultValue($defaults['config']['agent'])->end()
95 ->integerNode('redirect')->min(1)->max(30)->defaultValue($defaults['config']['redirect'])->end()
99 ->addDefaultsIfNotSet()
101 ->scalarNode('css')->cannotBeEmpty()->defaultValue($defaults['output']['css'])->end()
102 ->scalarNode('js')->cannotBeEmpty()->defaultValue($defaults['output']['js'])->end()
103 ->scalarNode('img')->cannotBeEmpty()->defaultValue($defaults['output']['img'])->end()
106 ->arrayNode('filters')
107 ->addDefaultsIfNotSet()
110 #XXX: undocumented, see Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +513
111 ->addDefaultChildrenIfNoneSet()
114 ->scalarNode('class')
117 ->defaultValue($defaults['filters']['css']['class'])
121 ->treatNullLike(array())
122 ->defaultValue($defaults['filters']['css']['args'])
123 ->scalarPrototype()->end()
129 #XXX: undocumented, see Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +513
130 ->addDefaultChildrenIfNoneSet()
133 ->scalarNode('class')
136 ->defaultValue($defaults['filters']['js']['class'])
139 ->treatNullLike(array())
140 ->defaultValue($defaults['filters']['js']['args'])
141 ->scalarPrototype()->end()
147 #XXX: undocumented, see Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +513
148 ->addDefaultChildrenIfNoneSet()
151 ->scalarNode('class')
154 ->defaultValue($defaults['filters']['img']['class'])
157 ->treatNullLike(array())
158 ->defaultValue($defaults['filters']['img']['args'])
159 ->scalarPrototype()->end()