mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Making JsonView work more like the XmlView.
This commit is contained in:
parent
011fd51539
commit
5e9b1583e5
3 changed files with 14 additions and 2 deletions
|
@ -53,10 +53,14 @@ class JsonViewTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testRenderWithView() {
|
public function testRenderWithView() {
|
||||||
App::build(array('View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Json')));
|
App::build(array(
|
||||||
|
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
|
||||||
|
));
|
||||||
$Request = new CakeRequest();
|
$Request = new CakeRequest();
|
||||||
$Response = new CakeResponse();
|
$Response = new CakeResponse();
|
||||||
$Controller = new Controller($Request, $Response);
|
$Controller = new Controller($Request, $Response);
|
||||||
|
$Controller->name = $Controller->viewPath = 'Posts';
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'User' => array(
|
'User' => array(
|
||||||
'username' => 'fake'
|
'username' => 'fake'
|
||||||
|
|
|
@ -24,4 +24,4 @@ foreach ($user['Item'] as $item) {
|
||||||
$formatted['list'][] = $item['name'];
|
$formatted['list'][] = $item['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->set('serialize', $formatted);
|
echo json_encode($formatted);
|
|
@ -36,6 +36,14 @@ App::uses('View', 'View');
|
||||||
*/
|
*/
|
||||||
class JsonView extends View {
|
class JsonView extends View {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JSON views are always located in the 'json' sub directory for a
|
||||||
|
* controllers views.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $subDir = 'json';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue