JsonViewHelper
class JsonViewHelper extends AbstractViewHelper (View source)
Wrapper for PHPs json_encode function.
= Examples =
{someArray -> f:format.json()}
<output>
["array","values"]
// depending on the value of {someArray}
</output>
<code title="associative array">
{f:format.json(value: {foo: 'bar', bar: 'baz'})}
{f:format.json(value: {0: 'bar', 1: 'baz'}, forceObject: true)}
<output>
{"0":"bar","1":"baz"}
</output>
Properties
protected RenderingContextInterface | $renderingContext | from AbstractViewHelper | |
protected ControllerContext | $controllerContext | Controller Context to use |
from AbstractViewHelper |
protected ObjectManagerInterface | $objectManager | from AbstractViewHelper | |
protected LoggerInterface | $logger | from AbstractViewHelper | |
protected bool | $escapeChildren |
Methods
No description
Injects the (system) logger based on PSR-3.
Initialize the arguments.
Outputs content with its JSON representation. To prevent issues in HTML context, occurrences of greater-than or less-than characters are converted to their hexadecimal representations.
No description
Details
void
setRenderingContext(RenderingContextInterface $renderingContext)
No description
void
injectObjectManager(ObjectManagerInterface $objectManager)
No description
void
injectLogger(LoggerInterface $logger)
Injects the (system) logger based on PSR-3.
bool
isEscapingInterceptorEnabled()
No description
void
initializeArguments()
Initialize the arguments.
string
render()
Outputs content with its JSON representation. To prevent issues in HTML context, occurrences of greater-than or less-than characters are converted to their hexadecimal representations.
If $forceObject is true a JSON object is outputted even if the value is a non-associative array Example: array('foo', 'bar') as input will not be ["foo","bar"] but {"0":"foo","1":"bar"}
string
compile(string $argumentsName, string $closureName, string $initializationPhpCode, ViewHelperNode $node, TemplateCompiler $compiler)
No description