[FrameworkBundle] Fix Templating Engine autowiring

This commit is contained in:
Kévin Dunglas 2016-03-26 07:49:03 +01:00 committed by Fabien Potencier
parent fa01e848d0
commit c4ccfac047
4 changed files with 11 additions and 9 deletions

View File

@ -11,8 +11,10 @@
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
class TemplatingPass implements CompilerPassInterface
{
@ -22,6 +24,11 @@ class TemplatingPass implements CompilerPassInterface
return;
}
if ($container->hasAlias('templating')) {
$definition = $container->findDefinition('templating');
$definition->setAutowiringTypes(array(ComponentEngineInterface::class, FrameworkBundleEngineInterface::class));
}
if ($container->hasDefinition('templating.engine.php')) {
$helpers = array();
foreach ($container->findTaggedServiceIds('templating.helper') as $id => $attributes) {

View File

@ -8,9 +8,6 @@
<service id="templating.engine.delegating" class="Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine" public="false">
<argument type="service" id="service_container" />
<argument type="collection" /> <!-- engines -->
<autowiring-type>Symfony\Component\Templating\EngineInterface</autowiring-type>
<autowiring-type>Symfony\Bundle\FrameworkBundle\Templating\EngineInterface</autowiring-type>
</service>
<service id="templating.name_parser" class="Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser">

View File

@ -13,7 +13,8 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine;
use Symfony\Component\Templating\EngineInterface;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
class AutowiringTypesTest extends WebTestCase
{
@ -41,8 +42,8 @@ class AutowiringTypesTest extends WebTestCase
$container = static::$kernel->getContainer();
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
$this->assertInstanceOf(DelegatingEngine::class, $autowiredServices->getFrameworkBundleEngine());
$this->assertInstanceOf(DelegatingEngine::class, $autowiredServices->getEngine());
$this->assertInstanceOf(FrameworkBundleEngineInterface::class, $autowiredServices->getFrameworkBundleEngine());
$this->assertInstanceOf(EngineInterface::class, $autowiredServices->getEngine());
}
protected static function createKernel(array $options = array())

View File

@ -59,9 +59,6 @@
<argument type="service" id="twig" />
<argument type="service" id="templating.name_parser" />
<argument type="service" id="templating.locator" />
<autowiring-type>Symfony\Component\Templating\EngineInterface</autowiring-type>
<autowiring-type>Symfony\Bundle\FrameworkBundle\Templating\EngineInterface</autowiring-type>
</service>
<service id="twig.extension.profiler" class="Symfony\Bridge\Twig\Extension\ProfilerExtension" public="false">