Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 26ed582

Browse filesBrowse files
committed
[FrameworkBundle][TwigBundle] Make EngineInterface autowirable
1 parent 83ebf97 commit 26ed582
Copy full SHA for 26ed582

File tree

Expand file treeCollapse file tree

5 files changed

+37
-1
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+37
-1
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
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>
1114
</service>
1215

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

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\Common\Annotations\AnnotationReader;
1515
use Doctrine\Common\Annotations\CachedReader;
16+
use Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine;
1617

1718
class AutowiringTypesTest extends WebTestCase
1819
{
@@ -34,6 +35,16 @@ public function testCachedAnnotationReaderAutowiring()
3435
$this->assertInstanceOf(CachedReader::class, $annotationReader);
3536
}
3637

38+
public function testTemplatingAutowiring()
39+
{
40+
static::bootKernel();
41+
$container = static::$kernel->getContainer();
42+
43+
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
44+
$this->assertInstanceOf(DelegatingEngine::class, $autowiredServices->getFrameworkBundleEngine());
45+
$this->assertInstanceOf(DelegatingEngine::class, $autowiredServices->getEngine());
46+
}
47+
3748
protected static function createKernel(array $options = array())
3849
{
3950
return parent::createKernel(array('test_case' => 'AutowiringTypes') + $options);

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php
+17-1Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,34 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes;
1313

1414
use Doctrine\Common\Annotations\Reader;
15+
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
16+
use Symfony\Component\Templating\EngineInterface;
1517

1618
class AutowiredServices
1719
{
1820
private $annotationReader;
21+
private $frameworkBundleEngine;
22+
private $engine;
1923

20-
public function __construct(Reader $annotationReader = null)
24+
public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine)
2125
{
2226
$this->annotationReader = $annotationReader;
27+
$this->frameworkBundleEngine = $frameworkBundleEngine;
28+
$this->engine = $engine;
2329
}
2430

2531
public function getAnnotationReader()
2632
{
2733
return $this->annotationReader;
2834
}
35+
36+
public function getFrameworkBundleEngine()
37+
{
38+
return $this->frameworkBundleEngine;
39+
}
40+
41+
public function getEngine()
42+
{
43+
return $this->engine;
44+
}
2945
}

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/config.yml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/config.yml
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ services:
55
test.autowiring_types.autowired_services:
66
class: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes\AutowiredServices
77
autowire: true
8+
framework:
9+
templating:
10+
engines: ['php']

‎src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
<argument type="service" id="twig" />
6060
<argument type="service" id="templating.name_parser" />
6161
<argument type="service" id="templating.locator" />
62+
63+
<autowiring-type>Symfony\Component\Templating\EngineInterface</autowiring-type>
64+
<autowiring-type>Symfony\Bundle\FrameworkBundle\Templating\EngineInterface</autowiring-type>
6265
</service>
6366

6467
<service id="twig.extension.profiler" class="Symfony\Bridge\Twig\Extension\ProfilerExtension" public="false">

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.