Skip to content

Commit

Permalink
added support for configuring sprockets include dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
kriswallsmith committed Jul 10, 2011
1 parent 455e176 commit 61bc7f3
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 2 additions & 0 deletions AsseticBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler\CheckCssEmbedFilterPass;
use Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler\CheckClosureFilterPass;
use Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler\TemplatingPass;
use Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler\SprocketsFilterPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

Expand All @@ -35,6 +36,7 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new CheckClosureFilterPass());
$container->addCompilerPass(new CheckCssEmbedFilterPass());
$container->addCompilerPass(new CheckYuiFilterPass());
$container->addCompilerPass(new SprocketsFilterPass());
$container->addCompilerPass(new TemplatingPass());
$container->addCompilerPass(new AssetFactoryPass());
$container->addCompilerPass(new AssetManagerPass());
Expand Down
35 changes: 35 additions & 0 deletions DependencyInjection/Compiler/SprocketsFilterPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

/**
* Finishes configuration of the Sprockets filter.
*
* @author Kris Wallsmith <[email protected]>
*/
class SprocketsFilterPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('assetic.filter.sprockets')) {
return;
}

$filter = $container->getDefinition('assetic.filter.sprockets');
foreach ($container->getParameter('assetic.filter.sprockets.include_dirs') as $dir) {
$filter->addMethodCall('addIncludeDir', array($dir));
}
}
}
1 change: 1 addition & 0 deletions Resources/config/filters/sprockets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<parameter key="assetic.filter.sprockets.class">Assetic\Filter\SprocketsFilter</parameter>
<parameter key="assetic.filter.sprockets.bin">/usr/bin/sprocketize</parameter>
<parameter key="assetic.filter.sprockets.asset_root">%assetic.write_to%</parameter>
<parameter key="assetic.filter.sprockets.include_dirs" type="collection" />
</parameters>

<services>
Expand Down
2 changes: 1 addition & 1 deletion Tests/DependencyInjection/AsseticExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function getFilterNames()
array('pngout'),
array('sass'),
array('scss'),
array('sprockets'),
array('sprockets', array('include_dirs' => array('foo'))),
array('stylus'),
array('yui_css', array('jar' => '/path/to/yuicompressor.jar')),
array('yui_js', array('jar' => '/path/to/yuicompressor.jar')),
Expand Down

0 comments on commit 61bc7f3

Please sign in to comment.