Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ensure callbacks are triggered when using Xml/Json view with view tem…

…plates.

PaginatorHelper for instance needs this to correctly set options
  • Loading branch information...
commit e7dc23b920ac1b1b4825d57538a12c395939ba20 1 parent 62dd391
@ceeram ceeram authored
View
4 lib/Cake/Test/Case/View/JsonViewTest.php
@@ -76,6 +76,7 @@ public function testRenderWithView() {
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
));
$Request = new CakeRequest();
+ $Request->params['named'] = array('page' => 2);
$Response = new CakeResponse();
$Controller = new Controller($Request, $Response);
$Controller->name = $Controller->viewPath = 'Posts';
@@ -91,9 +92,10 @@ public function testRenderWithView() {
);
$Controller->set('user', $data);
$View = new JsonView($Controller);
+ $View->helpers = array('Paginator');
$output = $View->render('index');
- $expected = json_encode(array('user' => 'fake', 'list' => array('item1', 'item2')));
+ $expected = json_encode(array('user' => 'fake', 'list' => array('item1', 'item2'), 'paging' => array('page' => 2)));
$this->assertSame($expected, $output);
$this->assertSame('application/json', $Response->type());
}
View
5 lib/Cake/Test/test_app/View/Posts/json/index.ctp
@@ -16,9 +16,12 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+$paging = isset($this->Paginator->options['url']) ? $this->Paginator->options['url'] : null;
+
$formatted = array(
'user' => $user['User']['username'],
- 'list' => array()
+ 'list' => array(),
+ 'paging' => $paging,
);
foreach ($user['Item'] as $item) {
$formatted['list'][] = $item['name'];
View
7 lib/Cake/View/JsonView.php
@@ -85,12 +85,7 @@ public function render($view = null, $layout = null) {
return $this->_serialize($this->viewVars['_serialize']);
}
if ($view !== false && $viewFileName = $this->_getViewFileName($view)) {
- if (!$this->_helpersLoaded) {
- $this->loadHelpers();
- }
- $content = $this->_render($viewFileName);
- $this->Blocks->set('content', $content);
- return $content;
+ return parent::render($view, false);
}
}
View
7 lib/Cake/View/XmlView.php
@@ -88,12 +88,7 @@ public function render($view = null, $layout = null) {
return $this->_serialize($this->viewVars['_serialize']);
}
if ($view !== false && $viewFileName = $this->_getViewFileName($view)) {
- if (!$this->_helpersLoaded) {
- $this->loadHelpers();
- }
- $content = $this->_render($viewFileName);
- $this->Blocks->set('content', (string)$content);
- return $content;
+ return parent::render($view, false);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.