Neos\Flow\Mvc\View\JsonView::setVariablesToRender PHP Method

setVariablesToRender() public method

Specifies which variables this JsonView should render By default only the variable 'value' will be rendered
public setVariablesToRender ( array $variablesToRender ) : void
$variablesToRender array
return void
    public function setVariablesToRender(array $variablesToRender)
    {
        $this->variablesToRender = $variablesToRender;
    }

Usage Example

 /**
  * @test
  */
 public function viewAcceptsJsonEncodingOptions()
 {
     $array = ['foo' => ['bar' => 'Baz', 'foo' => '1']];
     $this->view->setOption('jsonEncodingOptions', JSON_PRETTY_PRINT);
     $this->view->assign('array', $array);
     $this->view->setVariablesToRender(['array']);
     $expectedResult = json_encode($array, JSON_PRETTY_PRINT);
     $actualResult = $this->view->render();
     $this->assertEquals($expectedResult, $actualResult);
     $unexpectedResult = json_encode($array);
     $this->assertNotEquals($unexpectedResult, $actualResult);
 }