diff --git a/src/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php b/src/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php
index 1284628dde..19ee3dcfc3 100644
--- a/src/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php
+++ b/src/Symfony/Bundle/AsseticBundle/DependencyInjection/AsseticExtension.php
@@ -71,6 +71,9 @@ class AsseticExtension extends Extension
}
}
+ // twig functions
+ $container->getDefinition('assetic.twig_extension')->replaceArgument(2, $config['twig']['functions']);
+
// choose dynamic or static
if ($parameterBag->resolveValue($parameterBag->get('assetic.use_controller'))) {
$loader->load('controller.xml');
diff --git a/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php
index 76d20263c1..16c45c0228 100644
--- a/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/AsseticBundle/DependencyInjection/Configuration.php
@@ -91,6 +91,29 @@ class Configuration implements ConfigurationInterface
->end()
->end()
->end()
+
+ // twig
+ ->children()
+ ->arrayNode('twig')
+ ->addDefaultsIfNotSet()
+ ->defaultValue(array())
+ ->fixXmlConfig('function')
+ ->children()
+ ->arrayNode('functions')
+ ->addDefaultsIfNotSet()
+ ->defaultValue(array())
+ ->useAttributeAsKey('name')
+ ->prototype('variable')
+ ->treatNullLike(array())
+ ->validate()
+ ->ifTrue(function($v) { return !is_array($v); })
+ ->thenInvalid('The assetic.twig.functions config %s must be either null or an array.')
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->end()
+ ->end()
;
return $builder;
diff --git a/src/Symfony/Bundle/AsseticBundle/Resources/config/schema/assetic-1.0.xsd b/src/Symfony/Bundle/AsseticBundle/Resources/config/schema/assetic-1.0.xsd
index 1d63ea187f..e2928fd13a 100644
--- a/src/Symfony/Bundle/AsseticBundle/Resources/config/schema/assetic-1.0.xsd
+++ b/src/Symfony/Bundle/AsseticBundle/Resources/config/schema/assetic-1.0.xsd
@@ -11,6 +11,7 @@
+
@@ -32,4 +33,15 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Symfony/Bundle/AsseticBundle/Resources/config/templating_twig.xml b/src/Symfony/Bundle/AsseticBundle/Resources/config/templating_twig.xml
index a2340dc316..1a32250152 100644
--- a/src/Symfony/Bundle/AsseticBundle/Resources/config/templating_twig.xml
+++ b/src/Symfony/Bundle/AsseticBundle/Resources/config/templating_twig.xml
@@ -14,8 +14,8 @@
- %assetic.debug%
%assetic.use_controller%
+
diff --git a/src/Symfony/Bundle/AsseticBundle/Tests/Resources/config/config.yml b/src/Symfony/Bundle/AsseticBundle/Tests/Resources/config/config.yml
index 1049c0e4a7..bbc87b4daa 100644
--- a/src/Symfony/Bundle/AsseticBundle/Tests/Resources/config/config.yml
+++ b/src/Symfony/Bundle/AsseticBundle/Tests/Resources/config/config.yml
@@ -20,3 +20,9 @@ assetic:
use_controller: true
read_from: "%kernel.root_dir%/web"
bundles: [TestBundle]
+ filters:
+ yui_css:
+ jar: %kernel.root_dir/java/yui-compressor-2.4.6.jar
+ twig:
+ functions:
+ yui_css: { output: css/*.css }
diff --git a/src/Symfony/Bundle/AsseticBundle/Twig/AsseticExtension.php b/src/Symfony/Bundle/AsseticBundle/Twig/AsseticExtension.php
index e5302ed71c..ba76a9e18f 100644
--- a/src/Symfony/Bundle/AsseticBundle/Twig/AsseticExtension.php
+++ b/src/Symfony/Bundle/AsseticBundle/Twig/AsseticExtension.php
@@ -23,9 +23,9 @@ class AsseticExtension extends BaseAsseticExtension
{
private $useController;
- public function __construct(AssetFactory $factory, $debug = false, $useController = false)
+ public function __construct(AssetFactory $factory, $useController = false, $functions = array())
{
- parent::__construct($factory, $debug);
+ parent::__construct($factory, $functions);
$this->useController = $useController;
}