From 6e1b1df2b28a59bdaf5025e187d2077c10c2eeb6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 22 Nov 2011 20:56:25 -0500 Subject: [PATCH] Change serialize to _serialize Its possible that a developer would use 'serialize' as a legitimate view variable. Prefix with an _ to minimize that. --- lib/Cake/Test/Case/View/JsonViewTest.php | 6 +++--- lib/Cake/Test/Case/View/XmlViewTest.php | 6 +++--- lib/Cake/View/JsonView.php | 18 +++++++++--------- lib/Cake/View/XmlView.php | 18 +++++++++--------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index fe4caedd0..e01f5c3d2 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -39,7 +39,7 @@ class JsonViewTest extends CakeTestCase { $Response = new CakeResponse(); $Controller = new Controller($Request, $Response); $data = array('user' => 'fake', 'list' => array('item1', 'item2')); - $Controller->set(array('data' => $data, 'serialize' => 'data')); + $Controller->set(array('data' => $data, '_serialize' => 'data')); $View = new JsonView($Controller); $output = $View->render(false); @@ -48,7 +48,7 @@ class JsonViewTest extends CakeTestCase { } /** - * Test render with an array in serialize + * Test render with an array in _serialize * * @return void */ @@ -58,7 +58,7 @@ class JsonViewTest extends CakeTestCase { $Controller = new Controller($Request, $Response); $data = array('no' => 'nope', 'user' => 'fake', 'list' => array('item1', 'item2')); $Controller->set($data); - $Controller->set('serialize', array('no', 'user')); + $Controller->set('_serialize', array('no', 'user')); $View = new JsonView($Controller); $output = $View->render(false); diff --git a/lib/Cake/Test/Case/View/XmlViewTest.php b/lib/Cake/Test/Case/View/XmlViewTest.php index 4e4f4e875..b25894ea4 100644 --- a/lib/Cake/Test/Case/View/XmlViewTest.php +++ b/lib/Cake/Test/Case/View/XmlViewTest.php @@ -39,7 +39,7 @@ class XmlViewTest extends CakeTestCase { $Response = new CakeResponse(); $Controller = new Controller($Request, $Response); $data = array('users' => array('user' => array('user1', 'user2'))); - $Controller->set(array('users' => $data, 'serialize' => 'users')); + $Controller->set(array('users' => $data, '_serialize' => 'users')); $View = new XmlView($Controller); $output = $View->render(false); @@ -49,7 +49,7 @@ class XmlViewTest extends CakeTestCase { } /** - * Test render with an array in serialize + * Test render with an array in _serialize * * @return void */ @@ -59,7 +59,7 @@ class XmlViewTest extends CakeTestCase { $Controller = new Controller($Request, $Response); $data = array('no' => 'nope', 'user' => 'fake', 'list' => array('item1', 'item2')); $Controller->set($data); - $Controller->set('serialize', array('no', 'user')); + $Controller->set('_serialize', array('no', 'user')); $View = new XmlView($Controller); $output = $View->render(false); diff --git a/lib/Cake/View/JsonView.php b/lib/Cake/View/JsonView.php index 14e9326f9..538ce1df1 100644 --- a/lib/Cake/View/JsonView.php +++ b/lib/Cake/View/JsonView.php @@ -16,31 +16,31 @@ App::uses('View', 'View'); /** * A view class that is used for JSON responses. * - * By setting the 'serialize' key in your controller, you can specify a view variable + * By setting the '_serialize' key in your controller, you can specify a view variable * that should be serialized to JSON and used as the response for the request. * This allows you to omit views + layouts, if your just need to emit a single view * variable as the JSON response. * * In your controller, you could do the following: * - * `$this->set(array('posts' => $posts, 'serialize' => 'posts'));` + * `$this->set(array('posts' => $posts, '_serialize' => 'posts'));` * * When the view is rendered, the `$posts` view variable will be serialized * into JSON. * - * You can also define `'serialize'` as an array. This will create a top level object containing + * You can also define `'_serialize'` as an array. This will create a top level object containing * all the named view variables: * * {{{ * $this->set(compact('posts', 'users', 'stuff')); - * $this->set('serialize', array('posts', 'users')); + * $this->set('_serialize', array('posts', 'users')); * }}} * * The above would generate a JSON object that looks like: * * `{"posts": [...], "users": [...]}` * - * If you don't use the `serialize` key, you will need a view. You can use extended + * If you don't use the `_serialize` key, you will need a view. You can use extended * views to provide layout like functionality. * * @package Cake.View @@ -73,9 +73,9 @@ class JsonView extends View { /** * Render a JSON view. * - * Uses the special 'serialize' parameter to convert a set of + * Uses the special '_serialize' parameter to convert a set of * view variables into a JSON response. Makes generating simple - * JSON responses very easy. You can omit the 'serialize' parameter, + * JSON responses very easy. You can omit the '_serialize' parameter, * and use a normal view + layout as well. * * @param string $view The view being rendered. @@ -83,8 +83,8 @@ class JsonView extends View { * @return string The rendered view. */ public function render($view = null, $layout = null) { - if (isset($this->viewVars['serialize'])) { - $serialize = $this->viewVars['serialize']; + if (isset($this->viewVars['_serialize'])) { + $serialize = $this->viewVars['_serialize']; if (is_array($serialize)) { $data = array(); foreach ($serialize as $key) { diff --git a/lib/Cake/View/XmlView.php b/lib/Cake/View/XmlView.php index 25f01184e..f95d24312 100644 --- a/lib/Cake/View/XmlView.php +++ b/lib/Cake/View/XmlView.php @@ -17,33 +17,33 @@ App::uses('Xml', 'Utility'); /** * A view class that is used for creating XML responses. * - * By setting the 'serialize' key in your controller, you can specify a view variable + * By setting the '_serialize' key in your controller, you can specify a view variable * that should be serialized to XML and used as the response for the request. * This allows you to omit views + layouts, if your just need to emit a single view * variable as the XML response. * * In your controller, you could do the following: * - * `$this->set(array('posts' => $posts, 'serialize' => 'posts'));` + * `$this->set(array('posts' => $posts, '_serialize' => 'posts'));` * * When the view is rendered, the `$posts` view variable will be serialized * into XML. * * **Note** The view variable you specify must be compatible with Xml::fromArray(). * - * You can also define `'serialize'` as an array. This will create an additional + * You can also define `'_serialize'` as an array. This will create an additional * top level element named `` containing all the named view variables: * * {{{ * $this->set(compact('posts', 'users', 'stuff')); - * $this->set('serialize', array('posts', 'users')); + * $this->set('_serialize', array('posts', 'users')); * }}} * * The above would generate a XML object that looks like: * * `......` * - * If you don't use the `serialize` key, you will need a view. You can use extended + * If you don't use the `_serialize` key, you will need a view. You can use extended * views to provide layout like functionality. * * @package Cake.View @@ -74,9 +74,9 @@ class XmlView extends View { /** * Render a XML view. * - * Uses the special 'serialize' parameter to convert a set of + * Uses the special '_serialize' parameter to convert a set of * view variables into a XML response. Makes generating simple - * XML responses very easy. You can omit the 'serialize' parameter, + * XML responses very easy. You can omit the '_serialize' parameter, * and use a normal view + layout as well. * * @param string $view The view being rendered. @@ -84,8 +84,8 @@ class XmlView extends View { * @return string The rendered view. */ public function render($view = null, $layout = null) { - if (isset($this->viewVars['serialize'])) { - $serialize = $this->viewVars['serialize']; + if (isset($this->viewVars['_serialize'])) { + $serialize = $this->viewVars['_serialize']; if (is_array($serialize)) { $data = array('response' => array()); foreach ($serialize as $key) {