symfony/symfony — pull request #12282 by blanchonvincent (2014-10-22 06:56:47+00:00)
Title: Add engine aware trait + interface

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -

Currently, when a service need the template engine, I have a code like this :

```php
class MyAwesomeListener implements EventSubscriberInterface
{
/**
* @var EngineInterface
*/
protected $renderer;

/**
* @param ContactEvent $event
*/
public function onMyAwesomeEvent(MyEvent $event)
{
// here I need to render a template
}

/**
* @param $renderer
*/
public function setRenderer(EngineInterface $renderer)
{
$this->renderer = $renderer;
}
}
```

With a trait, I just would like to reduce code to write and keep my classes skinny when a service need the template engine.