sensio/SensioFrameworkExtraBundle — Issue #87: Consider using namespaced request attribute keys
Author: jmikola
Created: 2011-12-28 06:07:00+00:00
State: open

Both [TemplateListener.php](https://github.com/sensio/SensioFrameworkExtraBundle/blob/master/EventListener/TemplateListener.php) and FOSRestBundle's [ViewResponseListener.php](https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/EventListener/ViewResponseListener.php) use the `_template` request attribute key for different purposes. Perhaps it would be wise to use a more unique key to avoid conflict.

See below for details:

```
hi is anyone here?
Fatal error: Call to undefined method Symfony\Bundle\FrameworkBundle\Templating\TemplateReference::getTemplate() in /var/www/tyler/skilltree.me/vendor/bundles/Sensio/Bundle/FrameworkExtraBundle/EventListener/TemplateListener.php on line 62
I'm getting this error after upgrading to 2.0.8 with the deps and deps.lock files from symfony-standard.
It seems something is out of sync
tystr: that object should be an instance of Sensio\Bundle\FrameworkExtraBundle\Configuration\Template
i can't find anything in symfony that sets the "_template" request attribute
hmm
it's the @Template() annotation on my method that's causing the error, for some reason
if you look at the bundle's TempalteListener::onKernelController() method
the guesser returns a TemplateReference object, which is passed to $configuration->setTemplate()
that's later set as the _template request attribute on line 65
https://github.com/sensio/SensioFrameworkExtraBundle/blob/master/EventListener/TemplateListener.php
i dunno why line 56 aborts if the request argument isn't set, as I don't see how it would be set at that point
but this explains the bad method call. are you perhaps running two controller calls in the same request?
it might just be a bug in the bundle
I just upgraded to 2.0.8...and this broke
aah
I also just installed FOSRestbundle
which is hijacking everything it seems...
it's quite possible they conflit
*conflict
i'm still curious how _template is even set to begin with for the framework extra bundle
does that request attribute get used anywhere in FOSRestBundle?
i imagine they might set it to a TemplateReference object directly
I dunno somehow it's overridnig the default behavior of the FrameworkExtraBundle
I find it odd that adding one third-party bundle completely alters the behavior of another third party bundle
adding sensio_framework_extra:
view: { annotations: false }
gets rid of the fatal errors, but now the controller is just returning the array instead of passing it to the view
tystr: https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/EventListener/ViewResponseListener.php#L52
they both fight over the _template request attribute
```