feature #18242 [FrameworkBundle][TwigBundle] Make EngineInterface autowirable (dunglas)
This PR was merged into the 3.1-dev branch.
Discussion
----------
[FrameworkBundle][TwigBundle] Make EngineInterface autowirable
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
Commits
-------
26ed582
[FrameworkBundle][TwigBundle] Make EngineInterface autowirable
This commit is contained in:
commit
3c75c48838
@ -8,6 +8,9 @@
|
|||||||
<service id="templating.engine.delegating" class="Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine" public="false">
|
<service id="templating.engine.delegating" class="Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine" public="false">
|
||||||
<argument type="service" id="service_container" />
|
<argument type="service" id="service_container" />
|
||||||
<argument type="collection" /> <!-- engines -->
|
<argument type="collection" /> <!-- engines -->
|
||||||
|
|
||||||
|
<autowiring-type>Symfony\Component\Templating\EngineInterface</autowiring-type>
|
||||||
|
<autowiring-type>Symfony\Bundle\FrameworkBundle\Templating\EngineInterface</autowiring-type>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="templating.name_parser" class="Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser">
|
<service id="templating.name_parser" class="Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser">
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
|
|||||||
|
|
||||||
use Doctrine\Common\Annotations\AnnotationReader;
|
use Doctrine\Common\Annotations\AnnotationReader;
|
||||||
use Doctrine\Common\Annotations\CachedReader;
|
use Doctrine\Common\Annotations\CachedReader;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine;
|
||||||
|
|
||||||
class AutowiringTypesTest extends WebTestCase
|
class AutowiringTypesTest extends WebTestCase
|
||||||
{
|
{
|
||||||
@ -34,6 +35,16 @@ class AutowiringTypesTest extends WebTestCase
|
|||||||
$this->assertInstanceOf(CachedReader::class, $annotationReader);
|
$this->assertInstanceOf(CachedReader::class, $annotationReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testTemplatingAutowiring()
|
||||||
|
{
|
||||||
|
static::bootKernel();
|
||||||
|
$container = static::$kernel->getContainer();
|
||||||
|
|
||||||
|
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
|
||||||
|
$this->assertInstanceOf(DelegatingEngine::class, $autowiredServices->getFrameworkBundleEngine());
|
||||||
|
$this->assertInstanceOf(DelegatingEngine::class, $autowiredServices->getEngine());
|
||||||
|
}
|
||||||
|
|
||||||
protected static function createKernel(array $options = array())
|
protected static function createKernel(array $options = array())
|
||||||
{
|
{
|
||||||
return parent::createKernel(array('test_case' => 'AutowiringTypes') + $options);
|
return parent::createKernel(array('test_case' => 'AutowiringTypes') + $options);
|
||||||
|
@ -12,18 +12,34 @@
|
|||||||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes;
|
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes;
|
||||||
|
|
||||||
use Doctrine\Common\Annotations\Reader;
|
use Doctrine\Common\Annotations\Reader;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
|
||||||
|
use Symfony\Component\Templating\EngineInterface;
|
||||||
|
|
||||||
class AutowiredServices
|
class AutowiredServices
|
||||||
{
|
{
|
||||||
private $annotationReader;
|
private $annotationReader;
|
||||||
|
private $frameworkBundleEngine;
|
||||||
|
private $engine;
|
||||||
|
|
||||||
public function __construct(Reader $annotationReader = null)
|
public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine)
|
||||||
{
|
{
|
||||||
$this->annotationReader = $annotationReader;
|
$this->annotationReader = $annotationReader;
|
||||||
|
$this->frameworkBundleEngine = $frameworkBundleEngine;
|
||||||
|
$this->engine = $engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAnnotationReader()
|
public function getAnnotationReader()
|
||||||
{
|
{
|
||||||
return $this->annotationReader;
|
return $this->annotationReader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFrameworkBundleEngine()
|
||||||
|
{
|
||||||
|
return $this->frameworkBundleEngine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEngine()
|
||||||
|
{
|
||||||
|
return $this->engine;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,3 +5,6 @@ services:
|
|||||||
test.autowiring_types.autowired_services:
|
test.autowiring_types.autowired_services:
|
||||||
class: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes\AutowiredServices
|
class: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes\AutowiredServices
|
||||||
autowire: true
|
autowire: true
|
||||||
|
framework:
|
||||||
|
templating:
|
||||||
|
engines: ['php']
|
||||||
|
@ -59,6 +59,9 @@
|
|||||||
<argument type="service" id="twig" />
|
<argument type="service" id="twig" />
|
||||||
<argument type="service" id="templating.name_parser" />
|
<argument type="service" id="templating.name_parser" />
|
||||||
<argument type="service" id="templating.locator" />
|
<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>
|
||||||
|
|
||||||
<service id="twig.extension.profiler" class="Symfony\Bridge\Twig\Extension\ProfilerExtension" public="false">
|
<service id="twig.extension.profiler" class="Symfony\Bridge\Twig\Extension\ProfilerExtension" public="false">
|
||||||
|
Reference in New Issue
Block a user