Skip to content

Commit

Permalink
I want to kill you ResourceResponseListener
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed Feb 7, 2015
1 parent b8bbcfe commit f7d95e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.4.4

* `ResourceResponseListener` only modifies response if it is a ResourceViewModel

## 0.4.3

* `isRootTemplate` now work even if you have called the `renderResource` helper inside a view
Expand Down
9 changes: 7 additions & 2 deletions src/Mvc/ResourceResponseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Zend\EventManager\EventManagerInterface;
use Zend\Http\Response as HttpResponse;
use Zend\Mvc\MvcEvent;
use ZfrRest\View\Model\ResourceViewModel;

/**
* HttpExceptionListener
Expand All @@ -48,9 +49,13 @@ public function attach(EventManagerInterface $events)
*/
public function finishResponse(MvcEvent $event)
{
$response = $event->getResponse();
$response = $event->getResponse();
$viewModel = $event->getViewModel();

if (!$response instanceof HttpResponse || null !== $event->getParam('exception')) {
if (!$response instanceof HttpResponse
|| null !== $event->getParam('exception')
|| !$viewModel instanceof ResourceViewModel
) {
return;
}

Expand Down

0 comments on commit f7d95e8

Please sign in to comment.