Skip to content

Commit

Permalink
do not set a format if one is already set in the View instance
Browse files Browse the repository at this point in the history
  • Loading branch information
lsmith77 committed Oct 9, 2011
1 parent 1c7ae10 commit 1d22038
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion EventListener/ViewResponseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ public function onKernelView(GetResponseForControllerResultEvent $event)
$view = new View($view);
}

$view->setFormat($request->getRequestFormat());
if (null === $view->getFormat()) {
$view->setFormat($request->getRequestFormat());
}

$vars = $request->attributes->get('_template_vars');
if (!$vars) {
Expand Down
4 changes: 2 additions & 2 deletions Tests/EventListener/ViewResponseListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public function testOnKernelView()

$view = $this->getMockBuilder('\FOS\RestBundle\View\View')->disableOriginalConstructor()->getMock();

$view->expects($this->once())
$view->expects($this->exactly(2))
->method('getFormat')
->will($this->returnValue('html'));
->will($this->onConsecutiveCalls(null, 'html'));

$viewHandler = $this->getMock('\FOS\RestBundle\View\ViewHandlerInterface');
$viewHandler->expects($this->once())
Expand Down

0 comments on commit 1d22038

Please sign in to comment.