Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #91 from symfony-cmf/tweak_fos_rest_integration
Browse files Browse the repository at this point in the history
improve json/xml output when params contain a single variable
  • Loading branch information
lsmith77 committed Nov 26, 2013
2 parents dc56f11 + 4c511c2 commit d27beb9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,11 @@
Changelog
=========

1.1.1
-----

* **2013-11-26**: Improve json/xml output when params contain a single variable

1.0.0-RC3
---------

Expand Down
7 changes: 7 additions & 0 deletions Controller/ContentController.php
Expand Up @@ -90,7 +90,14 @@ public function indexAction(Request $request, $contentDocument, $contentTemplate
protected function renderResponse($contentTemplate, $params)
{
if ($this->viewHandler) {
if (1 === count($params)) {
$templateVar = key($params);
$params = reset($params);
}
$view = new View($params);
if (isset($templateVar)) {
$view->setTemplateVar($templateVar);
}
$view->setTemplate($contentTemplate);

return $this->viewHandler->handle($view);
Expand Down

0 comments on commit d27beb9

Please sign in to comment.