Skip to content

Commit

Permalink
Change how a single view var is inferred with '_serialize' => true
Browse files Browse the repository at this point in the history
Now if a single view var is set it's inferred as `'_serialize' => ['var']`
instead of `'_serialize' => 'var'`.

Closes #7482
  • Loading branch information
ADmad committed Sep 30, 2015
1 parent 543b49b commit ddc3902
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/View/JsonView.php
Expand Up @@ -173,10 +173,6 @@ protected function _dataToSerialize($serialize = true)
return null;
}

if (count($data) === 1) {
return current($data);
}

return $data;
}

Expand Down
8 changes: 8 additions & 0 deletions tests/TestCase/View/JsonViewTest.php
Expand Up @@ -119,6 +119,14 @@ public static function renderWithoutViewProvider()
json_encode(['no' => 'nope', 'user' => 'fake', 'list' => ['item1', 'item2']])
],

// Test render with True in _serialize and single var
[
['no' => 'nope'],
true,
null,
json_encode(['no' => 'nope'])
],

// Test render with empty string in _serialize.
[
['no' => 'nope', 'user' => 'fake', 'list' => ['item1', 'item2']],
Expand Down

0 comments on commit ddc3902

Please sign in to comment.