Skip to content

Commit 8aa9fe7

Browse files
committed
Fixed AsseticTwigLoader patching to use the correct service
1 parent 0104dca commit 8aa9fe7

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/DependencyInjection/Compiler/ExclamationPass.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ public function process(ContainerBuilder $container)
3232
->addArgument(new Reference('kernel'));
3333

3434
// Patch assetic service when availible
35-
if ($container->hasDefinition('assetic.twig_formula_loader')) {
35+
if ($container->hasDefinition('assetic.twig_formula_loader.real')) {
36+
$container->getDefinition('assetic.twig_formula_loader.real')
37+
->setClass('%assetic.twig_formula_loader.class%');
38+
} elseif ($container->hasDefinition('assetic.twig_formula_loader')) {
3639
$container->getDefinition('assetic.twig_formula_loader')
3740
->setClass('%assetic.twig_formula_loader.class%');
3841
}

tests/DependencyInjection/Compiler/ExclamationPassTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@ public function it_should_change_the_templating_services_when_enabled()
4343
* @test
4444
*/
4545
public function it_should_change_the_assetic_service_when_enabled()
46+
{
47+
$this->setDefinition('templating.name_parser', new Definition(__CLASS__));
48+
$this->setDefinition('templating.cache_warmer.template_paths', new Definition(__CLASS__));
49+
$this->setDefinition('assetic.twig_formula_loader.real', new Definition(__CLASS__));
50+
$this->setDefinition('assetic.twig_formula_loader', new Definition(__CLASS__));
51+
52+
$this->setParameter('boekkooi.twig_jack.exclamation', true);
53+
54+
$this->setParameter('templating.name_parser.class', 'DummyNameParser');
55+
$this->setParameter('templating.cache_warmer.template_paths.class', 'DummyTemplatePaths');
56+
$this->setParameter('assetic.twig_formula_loader.class', 'DummyAssetic');
57+
58+
$this->compile();
59+
60+
$this->assertContainerBuilderHasService('assetic.twig_formula_loader.real', 'DummyAssetic');
61+
$this->assertContainerBuilderHasService('assetic.twig_formula_loader', __CLASS__);
62+
}
63+
64+
/**
65+
* @test
66+
*/
67+
public function it_should_change_the_assetic_service_when_enabled_fallback()
4668
{
4769
$this->setDefinition('templating.name_parser', new Definition(__CLASS__));
4870
$this->setDefinition('templating.cache_warmer.template_paths', new Definition(__CLASS__));
@@ -57,6 +79,7 @@ public function it_should_change_the_assetic_service_when_enabled()
5779
$this->compile();
5880

5981
$this->assertContainerBuilderHasService('assetic.twig_formula_loader', 'DummyAssetic');
82+
$this->assertContainerBuilderNotHasService('assetic.twig_formula_loader.real');
6083
}
6184

6285
/**

0 commit comments

Comments
 (0)