コード例 #1
0
ファイル: JsonViewTest.php プロジェクト: Mr-Robota/TYPO3.CMS
 /**
  * @test
  */
 public function descendAllKeepsArrayIndexes()
 {
     $array = array(array('name' => 'Foo', 'secret' => TRUE), array('name' => 'Bar', 'secret' => TRUE));
     $this->view->assign('value', $array);
     $this->view->setConfiguration(array('value' => array('_descendAll' => array('_descendAll' => array()))));
     $expectedResult = '[{"name":"Foo","secret":true},{"name":"Bar","secret":true}]';
     $actualResult = $this->view->render();
     $this->assertEquals($expectedResult, $actualResult);
 }
コード例 #2
0
ファイル: JsonView.php プロジェクト: t3dd/T3DD16.Backend
 /**
  * @inheritdoc
  * @return string
  */
 public function render()
 {
     if (count($this->variablesToRender) === 1) {
         $variableName = current($this->variablesToRender);
         $valueToRender = isset($this->variables[$variableName]) ? $this->variables[$variableName] : null;
         if ($valueToRender instanceof \JsonSerializable) {
             return json_encode($valueToRender);
         }
     }
     return parent::render();
 }