Skip to content

Commit 4407eb2

Browse files
committed
bug #18320 [FrameworkBundle] Fix Templating Engine autowiring (dunglas)
This PR was squashed before being merged into the 3.1-dev branch (closes #18320). Discussion ---------- [FrameworkBundle] Fix Templating Engine autowiring | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony#18242 (comment) | License | MIT | Doc PR | n/a Commits ------- c4ccfac [FrameworkBundle] Fix Templating Engine autowiring
2 parents 1247a7e + c0372d7 commit 4407eb2

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

DependencyInjection/Compiler/TemplatingPass.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14+
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
1415
use Symfony\Component\DependencyInjection\ContainerBuilder;
1516
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17+
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
1618

1719
class TemplatingPass implements CompilerPassInterface
1820
{
@@ -22,6 +24,11 @@ public function process(ContainerBuilder $container)
2224
return;
2325
}
2426

27+
if ($container->hasAlias('templating')) {
28+
$definition = $container->findDefinition('templating');
29+
$definition->setAutowiringTypes(array(ComponentEngineInterface::class, FrameworkBundleEngineInterface::class));
30+
}
31+
2532
if ($container->hasDefinition('templating.engine.php')) {
2633
$helpers = array();
2734
foreach ($container->findTaggedServiceIds('templating.helper') as $id => $attributes) {

Resources/config/templating.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
<service id="templating.engine.delegating" class="Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine" public="false">
99
<argument type="service" id="service_container" />
1010
<argument type="collection" /> <!-- engines -->
11-
12-
<autowiring-type>Symfony\Component\Templating\EngineInterface</autowiring-type>
13-
<autowiring-type>Symfony\Bundle\FrameworkBundle\Templating\EngineInterface</autowiring-type>
1411
</service>
1512

1613
<service id="templating.name_parser" class="Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser">

Tests/Functional/AutowiringTypesTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
use Doctrine\Common\Annotations\AnnotationReader;
1515
use Doctrine\Common\Annotations\CachedReader;
16-
use Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine;
16+
use Symfony\Component\Templating\EngineInterface;
17+
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
1718

1819
class AutowiringTypesTest extends WebTestCase
1920
{
@@ -41,8 +42,8 @@ public function testTemplatingAutowiring()
4142
$container = static::$kernel->getContainer();
4243

4344
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
44-
$this->assertInstanceOf(DelegatingEngine::class, $autowiredServices->getFrameworkBundleEngine());
45-
$this->assertInstanceOf(DelegatingEngine::class, $autowiredServices->getEngine());
45+
$this->assertInstanceOf(FrameworkBundleEngineInterface::class, $autowiredServices->getFrameworkBundleEngine());
46+
$this->assertInstanceOf(EngineInterface::class, $autowiredServices->getEngine());
4647
}
4748

4849
protected static function createKernel(array $options = array())

0 commit comments

Comments
 (0)