コード例 #1
0
 /**
  * @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
 /**
  * @test
  */
 public function renderTransformsJsonSerializableValues()
 {
     $value = $this->getMock('JsonSerializable', array('jsonSerialize'));
     $value->expects($this->any())->method('jsonSerialize')->will($this->returnValue(array('name' => 'Foo', 'age' => 42)));
     $this->view->assign('value', $value);
     $this->view->setConfiguration(array('value' => array('_only' => array('name'))));
     $expectedResult = '{"name":"Foo"}';
     $actualResult = $this->view->render();
     $this->assertEquals($expectedResult, $actualResult);
 }
コード例 #3
0
 /**
  * Configures rendering according to the set variable(s) and calls
  * render on the parent.
  *
  * @return string
  */
 public function render()
 {
     if (isset($this->variables['assets'])) {
         $this->setConfiguration(array('assets' => array('_descendAll' => array('_only' => array('label', 'tags', 'identifier')))));
         $this->setVariablesToRender(array('assets'));
     } else {
         $this->setConfiguration(array('asset' => array('_only' => array('label', 'tags', 'identifier'))));
         $this->setVariablesToRender(array('asset'));
     }
     return parent::render();
 }
コード例 #4
0
 /**
  * Configures rendering according to the set variable(s) and calls
  * render on the parent.
  *
  * @return string
  */
 public function render()
 {
     if (isset($this->variables['nodes'])) {
         $this->setConfiguration(array('nodes' => array('_descendAll' => array('_only' => array('name', 'path', 'identifier', 'properties', 'nodeType')))));
         $this->setVariablesToRender(array('nodes'));
     } else {
         $this->setConfiguration(array('node' => array('_only' => array('name', 'path', 'identifier', 'properties', 'nodeType'))));
         $this->setVariablesToRender(array('node'));
     }
     return parent::render();
 }
コード例 #5
0
 /**
  * Configures rendering according to the set variable(s) and calls
  * render on the parent.
  *
  * @return string
  */
 public function render()
 {
     if (isset($this->variables['workspaces'])) {
         $this->setConfiguration(array('workspaces' => array('_descendAll' => array())));
         $this->setVariablesToRender(array('workspaces'));
     } else {
         $this->setConfiguration(array('workspace' => array()));
         $this->setVariablesToRender(array('workspace'));
     }
     return parent::render();
 }
コード例 #6
0
 /**
  * @test
  */
 public function viewAcceptsJsonEncodingOptions()
 {
     $array = array('foo' => array('bar' => 'Baz', 'foo' => '1'));
     $this->view->setOption('jsonEncodingOptions', JSON_PRETTY_PRINT);
     $this->view->assign('array', $array);
     $this->view->setVariablesToRender(array('array'));
     $expectedResult = json_encode($array, JSON_PRETTY_PRINT);
     $actualResult = $this->view->render();
     $this->assertEquals($expectedResult, $actualResult);
     $unexpectedResult = json_encode($array);
     $this->assertNotEquals($unexpectedResult, $actualResult);
 }
コード例 #7
0
ファイル: JsonView.php プロジェクト: netlogix/jsonapiorg
 /**
  * Transforms the value view variable to a serializable
  * array represantion using a YAML view configuration and JSON encodes
  * the result.
  *
  * @return string The JSON encoded variables
  * @api
  */
 public function render()
 {
     $result = parent::render();
     $this->controllerContext->getResponse()->setHeader('Content-Type', $this->getOption('contentTypeHeader'));
     return $result;
 }
コード例 #8
0
 /**
  * Mark a list item as undone
  *
  * @param Item $item
  * @throws \TYPO3\Flow\Persistence\Exception\IllegalObjectTypeException
  */
 public function undoAction(Item $item)
 {
     $item->markAsUnDone();
     $this->itemRepository->update($item);
     $this->view->assign('value', array('type' => 'success:undo', 'entity' => get_class($item)));
 }