Permalink
Browse files

since there was no reaction about adjusting the SensioFrameworkBundle…

… priorities, moving the logic for handing the annotations back into FOSRestBundle
  • Loading branch information...
1 parent 0666d14 commit a30a28d6709ff712735cdb8e9e4c74b95613adb8 @lsmith77 lsmith77 committed Sep 12, 2011
Showing with 15 additions and 12 deletions.
  1. +7 −2 EventListener/ViewResponseListener.php
  2. +8 −4 README.md
  3. +0 −6 UPGRADING.md
View
9 EventListener/ViewResponseListener.php
@@ -16,6 +16,8 @@
Symfony\Bundle\FrameworkBundle\Templating\TemplateReference,
Symfony\Component\DependencyInjection\ContainerInterface;
+use Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener;
+
use FOS\RestBundle\View\View,
FOS\RestBundle\Controller\Annotations\View as ViewAnnotation;
@@ -24,12 +26,12 @@
*
* @author Lukas Kahwe Smith <smith@pooteeweet.org>
*/
-class ViewResponseListener
+class ViewResponseListener extends TemplateListener
{
/**
* @var Symfony\Component\DependencyInjection\ContainerInterface
*/
- private $container;
+ protected $container;
/**
* Constructor.
@@ -50,11 +52,14 @@ public function __construct(ContainerInterface $container)
public function onKernelController(FilterControllerEvent $event)
{
$request = $event->getRequest();
+
if (!$configuration = $request->attributes->get('_view')) {
return;
}
$request->attributes->set('_template', $configuration);
+
+ parent::onKernelController($event);
}
/**
View
12 README.md
@@ -292,15 +292,19 @@ The ``@View()`` and ``@Template()`` annotations behave essentially the same with
difference. When ``view_response_listener`` is set to ``true`` instead of the default ``force``
and ``@View()`` is not used, then rendering will be delegated to SensioFrameworkBundle.
+Note that its necessary to disable view annotations in SensioFrameworkBundle so that
+FOSRestBundle can take over the handling.
+
```yaml
# app/config/config.yml
fos_rest:
view:
- view_response_listener: true
-```
+ view_response_listener: force
-Note, ``@View()`` currently only works if the following patch is applied:
-https://github.com/sensio/SensioFrameworkExtraBundle/pull/57
+sensio_framework_extra:
+ view: { annotations: false }
+
+```
```php
<?php
View
6 UPGRADING.md
@@ -6,12 +6,6 @@ for major refactorings.
### upgrading from 0.5.0_old_serializer
- * In case you are using th SensioFrameworkExtra integration you must change
- sensio_framework_extra setting:
-
- sensio_framework_extra:
- view: { annotations: true }
-
* The ViewInterface is gone so you might have to change your controller config if you refer to the fos_rest.view service.
* The View class is now split into a View (simple data container) and a ViewHandler (contains the actual rendering logic).

0 comments on commit a30a28d

Please sign in to comment.