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
{
15 //Constructor required to derivate prefix from kernel.project_dir
16 public function __construct(\
string $projectDir) {
17 $this->projectDir
= $projectDir;
23 public function getConfigTreeBuilder() {
24 $treeBuilder = new TreeBuilder();
25 $finder = new ExecutableFinder();
27 #TODO: see how we deal with asset url generation: see Rapsys/PackBundle/Twig/PackTokenParser.php +243
35 ## Force cache disable to regenerate resources each time
39 //Here we define the parameters that are allowed to configure the bundle.
40 //TODO: see https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php for default value and description
41 //TODO: see http://symfony.com/doc/current/components/config/definition.html
42 //TODO: see https://github.com/symfony/assetic-bundle/blob/master/DependencyInjection/Configuration.php#L63
43 //TODO: use bin/console config:dump-reference to dump class infos
48 ->arrayNode('rapsys_pack')
50 ->scalarNode('coutput')->defaultValue('css/*.pack.css')->end()
51 ->scalarNode('joutput')->defaultValue('js/*.pack.js')->end()
52 ->scalarNode('ioutput')->defaultValue('img/*.pack.jpg')->end()
53 ->arrayNode('cfilter')
54 ->treatNullLike(array())
55 ->scalarPrototype()->end()
56 ->defaultValue(array('Rapsys\PackBundle\Twig\Filter\CPackFilter'))
58 ->arrayNode('jfilter')
59 ->treatNullLike(array())
60 ->scalarPrototype()->end()
61 ->defaultValue(array('Rapsys\PackBundle\Twig\Filter\JPackFilter'))
63 ->arrayNode('ifilter')
64 ->treatNullLike(array())
65 ->scalarPrototype()->end()
66 ->defaultValue(array('Rapsys\PackBundle\Twig\Filter\IPackFilter'))
68 ->scalarNode('prefix')->defaultValue($this->projectDir
)->end()
69 ->scalarNode('scheme')->defaultValue('https://')->end()
70 ->integerNode('timeout')->min(0)->defaultValue((int)ini_get('default_socket_timeout'))->end()
71 ->scalarNode('agent')->defaultValue(ini_get('user_agent'))->end()
72 ->integerNode('redirect')->min(1)->defaultValue(20)->end()
75 ->arrayNode('rapsys_pack_cpackfilter')
77 ->scalarNode('bin')->defaultValue(function () use ($finder) { return $finder
->find('cpack', '/usr/local/bin/cpack'); })->end()
80 ->arrayNode('rapsys_pack_jpackfilter')
82 ->scalarNode('bin')->defaultValue(function () use ($finder) { return $finder
->find('jpack', '/usr/local/bin/jpack'); })->end()