JSON renderer

 Methods

Can this renderer render trees of view models?

canRenderTrees() : true

Yes.

Returns

true

Return the template engine object, if any

getEngine() : mixed

If using a third-party template engine, such as Smarty, patTemplate, phplib, etc, return the template engine object. Useful for calling methods on these objects, such as for setting filters, modifiers, etc.

Returns

mixed

Returns whether or not the jsonpCallback has been set

hasJsonpCallback() : bool

Returns

bool

Should we merge unnamed children?

mergeUnnamedChildren() : bool

Returns

bool

Renders values as JSON

render(string | \Zend\View\Model\ModelInterface $nameOrModel, null | array | \ArrayAccess $values) : string

todo Determine what use case exists for accepting both $nameOrModel and $values

Parameters

$nameOrModel

string\Zend\View\Model\ModelInterface

The script/resource process, or a view model

$values

nullarray\ArrayAccess

Values to use during rendering

Exceptions

\Zend\View\Exception\DomainException

Returns

stringThe script output.

Set the JSONP callback function name

setJsonpCallback(string $callback) : \Zend\View\Renderer\JsonRenderer

Parameters

$callback

string

Returns

Set flag indicating whether or not to merge unnamed children

setMergeUnnamedChildren(bool $mergeUnnamedChildren) : \Zend\View\Renderer\JsonRenderer

Parameters

$mergeUnnamedChildren

bool

Returns

Set the resolver used to map a template name to a resource the renderer may consume.

setResolver(\Zend\View\Resolver\ResolverInterface $resolver) : \Zend\View\Renderer\RendererInterface

todo Determine use case for resolvers when rendering JSON

Parameters

Returns

Inject discovered child model values into parent model

injectChildren(\Zend\View\Model\ModelInterface $model, array $children) 

todo detect collisions and decide whether to append and/or aggregate?

Parameters

$children

array

Retrieve values from a model and recurse its children to build a data structure

recurseModel(\Zend\View\Model\ModelInterface $model, bool $mergeWithVariables) : array

Parameters

$mergeWithVariables

bool

Whether or not to merge children with the variables of the $model

Returns

array

 Properties

 

JSONP callback (if set, wraps the return in a function call)

$jsonpCallback : string

 

Whether or not to merge child models with no capture-to value set

$mergeUnnamedChildren : bool

 

$resolver

$resolver : \Zend\View\Resolver\ResolverInterface