Skip to content

Commit

Permalink
bug #18320 [FrameworkBundle] Fix Templating Engine autowiring (dunglas)
Browse files Browse the repository at this point in the history
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 | #18242 (comment)
| License       | MIT
| Doc PR        | n/a

Commits
-------

c4ccfac [FrameworkBundle] Fix Templating Engine autowiring
  • Loading branch information
fabpot committed Mar 31, 2016
2 parents 536a6cd + c4ccfac commit f76e99b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
Expand Up @@ -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
{
Expand All @@ -22,6 +24,11 @@ public function process(ContainerBuilder $container)
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) {
Expand Down
Expand Up @@ -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">
Expand Down
Expand Up @@ -13,7 +13,8 @@

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
{
Expand Down Expand Up @@ -41,8 +42,8 @@ public function testTemplatingAutowiring()
$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())
Expand Down
3 changes: 0 additions & 3 deletions src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
Expand Up @@ -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">
Expand Down

0 comments on commit f76e99b

Please sign in to comment.