TYPO3 CMS  TYPO3_8-7
JsonViewHelper.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It originated from the Neos.Form package (www.neos.io)
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
22 
53 {
55 
59  protected $escapeChildren = false;
60 
64  public function initializeArguments()
65  {
66  $this->registerArgument('value', 'mixed', 'The incoming data to convert, or null if VH children should be used');
67  $this->registerArgument('forceObject', 'bool', 'Outputs an JSON object rather than an array', false, false);
68  }
69 
85  public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
86  {
87  $value = $renderChildrenClosure();
88  $options = JSON_HEX_TAG;
89  if ($arguments['forceObject'] !== false) {
90  $options = $options | JSON_FORCE_OBJECT;
91  }
92  return json_encode($value, $options);
93  }
94 }
static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)