Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

updated to work with twig formula loader changes #142

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
phpunit.xml
vendor
composer.lock
Tests/Resources/cache/
1 change: 0 additions & 1 deletion Resources/config/assetic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<parameter key="assetic.asset_factory.class">Symfony\Bundle\AsseticBundle\Factory\AssetFactory</parameter>
<parameter key="assetic.asset_manager.class">Assetic\Factory\LazyAssetManager</parameter>
<parameter key="assetic.asset_manager_cache_warmer.class">Symfony\Bundle\AsseticBundle\CacheWarmer\AssetManagerCacheWarmer</parameter>
<parameter key="assetic.cached_formula_loader.class">Assetic\Factory\Loader\CachedFormulaLoader</parameter>
<parameter key="assetic.config_cache.class">Assetic\Cache\ConfigCache</parameter>
<parameter key="assetic.config_loader.class">Symfony\Bundle\AsseticBundle\Factory\Loader\ConfigurationLoader</parameter>
<parameter key="assetic.config_resource.class">Symfony\Bundle\AsseticBundle\Factory\Resource\ConfigurationResource</parameter>
Expand Down
1 change: 1 addition & 0 deletions Resources/config/templating_php.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<parameter key="assetic.helper.dynamic.class">Symfony\Bundle\AsseticBundle\Templating\DynamicAsseticHelper</parameter>
<parameter key="assetic.helper.static.class">Symfony\Bundle\AsseticBundle\Templating\StaticAsseticHelper</parameter>
<parameter key="assetic.php_formula_loader.class">Symfony\Bundle\AsseticBundle\Factory\Loader\AsseticHelperFormulaLoader</parameter>
<parameter key="assetic.cached_formula_loader.class">Assetic\Factory\Loader\CachedFormulaLoader</parameter>
</parameters>

<services>
Expand Down
9 changes: 2 additions & 7 deletions Resources/config/templating_twig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,15 @@
<tag name="twig.extension" />
<tag name="assetic.templating.twig" />
<argument type="service" id="assetic.asset_factory" />
<argument type="service" id="assetic.config_cache" />
<argument type="service" id="templating.name_parser" />
<argument>%assetic.use_controller%</argument>
<argument>%assetic.twig_extension.functions%</argument>
<argument>%assetic.bundles%</argument>
<argument type="service" id="assetic.value_supplier" on-invalid="null" />
</service>
<service id="assetic.twig_formula_loader" class="%assetic.cached_formula_loader.class%" public="false">
<service id="assetic.twig_formula_loader" class="%assetic.twig_formula_loader.class%" public="false">
<tag name="assetic.formula_loader" alias="twig" />
<tag name="assetic.templating.twig" />
<argument type="service" id="assetic.twig_formula_loader.real" />
<argument type="service" id="assetic.config_cache" />
<argument>%kernel.debug%</argument>
</service>
<service id="assetic.twig_formula_loader.real" class="%assetic.twig_formula_loader.class%" public="false">
<tag name="assetic.templating.twig" />
<argument type="service" id="twig" />
</service>
Expand Down
13 changes: 2 additions & 11 deletions Tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,9 @@ protected function setUp()
}

$this->cacheDir = __DIR__.'/Resources/cache';
if (file_exists($this->cacheDir)) {
$filesystem = new Filesystem();
$filesystem->remove($this->cacheDir);
if (!file_exists($this->cacheDir)) {
mkdir($this->cacheDir, 0777, true);
}

mkdir($this->cacheDir, 0777, true);
}

protected function tearDown()
{
$filesystem = new Filesystem();
$filesystem->remove($this->cacheDir);
}

public function testTwigRenderDebug()
Expand Down
11 changes: 6 additions & 5 deletions Twig/AsseticExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

namespace Symfony\Bundle\AsseticBundle\Twig;

use Assetic\ValueSupplierInterface;
use Assetic\Cache\ConfigCache;
use Assetic\Extension\Twig\AsseticExtension as BaseAsseticExtension;
use Assetic\Factory\AssetFactory;
use Assetic\ValueSupplierInterface;
use Symfony\Component\Templating\TemplateNameParserInterface;

/**
Expand All @@ -27,9 +28,9 @@ class AsseticExtension extends BaseAsseticExtension
private $templateNameParser;
private $enabledBundles;

public function __construct(AssetFactory $factory, TemplateNameParserInterface $templateNameParser, $useController = false, $functions = array(), $enabledBundles = array(), ValueSupplierInterface $valueSupplier = null)
public function __construct(AssetFactory $factory, ConfigCache $cache, TemplateNameParserInterface $templateNameParser, $useController = false, $functions = array(), $enabledBundles = array(), ValueSupplierInterface $valueSupplier = null)
{
parent::__construct($factory, $functions, $valueSupplier);
parent::__construct($factory, $cache, $functions, $valueSupplier);

$this->useController = $useController;
$this->templateNameParser = $templateNameParser;
Expand All @@ -47,9 +48,9 @@ public function getTokenParsers()

public function getNodeVisitors()
{
return array(
return array_merge(parent::getNodeVisitors(), array(
new AsseticNodeVisitor($this->templateNameParser, $this->enabledBundles),
);
));
}

public function getGlobals()
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"require": {
"php": ">=5.3.0",
"symfony/framework-bundle": ">=2.1.0,<2.3-dev",
"kriswallsmith/assetic": "1.1.*"
"kriswallsmith/assetic": "dev-node-visitor"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be reverted before the merge (btw, should we release 1.1 first and bump Assetic to 1.2 with these changes ?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What stability is 1.1 at?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently, we only have alpha releases for 1.1 (but doing a stable release would be a great idea)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thus, changing the signature of the Twig extension is a BC break for everyone using Assetic and Twig standalone so I don't really like doing this before the 1.1 release

},
"require-dev": {
"symfony/twig-bundle": ">=2.1.0,<2.3-dev",
Expand Down