PHP Класс Neos\Flow\Mvc\View\JsonView

Наследование: extends AbstractView
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$configuration array The configuration array must have the following structure: Example 1: array( 'variable1' => array( '_only' => array('property1', 'property2', ...) ), 'variable2' => array( '_exclude' => array('property3', 'property4, ...) ), 'variable3' => array( '_exclude' => array('secretTitle'), '_descend' => array( 'customer' => array( '_only' => array('firstName', 'lastName') ) ) ), 'somearrayvalue' => array( '_descendAll' => array( '_only' => array('property1') ) ) ) Of variable1 only property1 and property2 will be included. Of variable2 all properties except property3 and property4 are used. Of variable3 all properties except secretTitle are included. If a property value is an array or object, it is not included by default. If, however, such a property is listed in a "_descend" section, the renderer will descend into this sub structure and include all its properties (of the next level). The configuration of each property in "_descend" has the same syntax like at the top level. Therefore - theoretically - infinitely nested structures can be configured. To export indexed arrays the "_descendAll" section can be used to include all array keys for the output. The configuration inside a "_descendAll" will be applied to each array element. Example 2: exposing object identifier array( 'variableFoo' => array( '_exclude' => array('secretTitle'), '_descend' => array( 'customer' => array( // consider 'customer' being a persisted entity '_only' => array('firstName'), '_exposeObjectIdentifier' => TRUE, '_exposedObjectIdentifierKey' => 'guid' ) ) ) ) Note for entity objects you are able to expose the object's identifier also, just add an "_exposeObjectIdentifier" directive set to TRUE and an additional property '__identity' will appear keeping the persistence identifier. Renaming that property name instead of '__identity' is also possible with the directive "_exposedObjectIdentifierKey". Example 2 above would output (summarized): {"customer":{"firstName":"John","guid":"892693e4-b570-46fe-af71-1ad32918fb64"}} Example 3: exposing object's class name array( 'variableFoo' => array( '_exclude' => array('secretTitle'), '_descend' => array( 'customer' => array( // consider 'customer' being an object '_only' => array('firstName'), '_exposeClassName' => Neos\Flow\Mvc\View\JsonView::EXPOSE_CLASSNAME_FULLY_QUALIFIED ) ) ) ) The _exposeClassName is similar to the objectIdentifier one, but the class name is added to the JSON object output, for example (summarized): {"customer":{"firstName":"John","__class":"Acme\Foo\Domain\Model\Customer"}} The other option is EXPOSE_CLASSNAME_UNQUALIFIED which only will give the last part of the class without the namespace, for example (summarized): {"customer":{"firstName":"John","__class":"Customer"}} This might be of interest to not provide information about the package or domain structure behind.
$controllerContext Neos\Flow\Mvc\Controller\ControllerContext
$persistenceManager Neos\Flow\Persistence\PersistenceManagerInterface
$supportedOptions array Supported options
$variablesToRender array Only variables whose name is contained in this array will be rendered

Открытые методы

Метод Описание
render ( ) : string Transforms the value view variable to a serializable array represantion using a YAML view configuration and JSON encodes the result.
setConfiguration ( array $configuration ) : void
setVariablesToRender ( array $variablesToRender ) : void Specifies which variables this JsonView should render By default only the variable 'value' will be rendered

Защищенные методы

Метод Описание
renderArray ( ) : array Loads the configuration and transforms the value to a serializable array.
transformObject ( object $object, array $configuration ) : array Traverses the given object structure in order to transform it into an array structure.
transformValue ( mixed $value, array $configuration ) : array Transforms a value depending on type recursively using the supplied configuration.

Описание методов

render() публичный Метод

Transforms the value view variable to a serializable array represantion using a YAML view configuration and JSON encodes the result.
public render ( ) : string
Результат string The JSON encoded variables

renderArray() защищенный Метод

Loads the configuration and transforms the value to a serializable array.
protected renderArray ( ) : array
Результат array An array containing the values, ready to be JSON encoded

setConfiguration() публичный Метод

public setConfiguration ( array $configuration ) : void
$configuration array The rendering configuration for this JSON view
Результат void

setVariablesToRender() публичный Метод

Specifies which variables this JsonView should render By default only the variable 'value' will be rendered
public setVariablesToRender ( array $variablesToRender ) : void
$variablesToRender array
Результат void

transformObject() защищенный Метод

Traverses the given object structure in order to transform it into an array structure.
protected transformObject ( object $object, array $configuration ) : array
$object object Object to traverse
$configuration array Configuration for transforming the given object or NULL
Результат array Object structure as an array

transformValue() защищенный Метод

Transforms a value depending on type recursively using the supplied configuration.
protected transformValue ( mixed $value, array $configuration ) : array
$value mixed The value to transform
$configuration array Configuration for transforming the value
Результат array The transformed value

Описание свойств

$configuration защищенное свойство

The configuration array must have the following structure: Example 1: array( 'variable1' => array( '_only' => array('property1', 'property2', ...) ), 'variable2' => array( '_exclude' => array('property3', 'property4, ...) ), 'variable3' => array( '_exclude' => array('secretTitle'), '_descend' => array( 'customer' => array( '_only' => array('firstName', 'lastName') ) ) ), 'somearrayvalue' => array( '_descendAll' => array( '_only' => array('property1') ) ) ) Of variable1 only property1 and property2 will be included. Of variable2 all properties except property3 and property4 are used. Of variable3 all properties except secretTitle are included. If a property value is an array or object, it is not included by default. If, however, such a property is listed in a "_descend" section, the renderer will descend into this sub structure and include all its properties (of the next level). The configuration of each property in "_descend" has the same syntax like at the top level. Therefore - theoretically - infinitely nested structures can be configured. To export indexed arrays the "_descendAll" section can be used to include all array keys for the output. The configuration inside a "_descendAll" will be applied to each array element. Example 2: exposing object identifier array( 'variableFoo' => array( '_exclude' => array('secretTitle'), '_descend' => array( 'customer' => array( // consider 'customer' being a persisted entity '_only' => array('firstName'), '_exposeObjectIdentifier' => TRUE, '_exposedObjectIdentifierKey' => 'guid' ) ) ) ) Note for entity objects you are able to expose the object's identifier also, just add an "_exposeObjectIdentifier" directive set to TRUE and an additional property '__identity' will appear keeping the persistence identifier. Renaming that property name instead of '__identity' is also possible with the directive "_exposedObjectIdentifierKey". Example 2 above would output (summarized): {"customer":{"firstName":"John","guid":"892693e4-b570-46fe-af71-1ad32918fb64"}} Example 3: exposing object's class name array( 'variableFoo' => array( '_exclude' => array('secretTitle'), '_descend' => array( 'customer' => array( // consider 'customer' being an object '_only' => array('firstName'), '_exposeClassName' => Neos\Flow\Mvc\View\JsonView::EXPOSE_CLASSNAME_FULLY_QUALIFIED ) ) ) ) The _exposeClassName is similar to the objectIdentifier one, but the class name is added to the JSON object output, for example (summarized): {"customer":{"firstName":"John","__class":"Acme\Foo\Domain\Model\Customer"}} The other option is EXPOSE_CLASSNAME_UNQUALIFIED which only will give the last part of the class without the namespace, for example (summarized): {"customer":{"firstName":"John","__class":"Customer"}} This might be of interest to not provide information about the package or domain structure behind.
protected array $configuration
Результат array

$controllerContext защищенное свойство

protected ControllerContext,Neos\Flow\Mvc\Controller $controllerContext
Результат Neos\Flow\Mvc\Controller\ControllerContext

$persistenceManager защищенное свойство

protected PersistenceManagerInterface,Neos\Flow\Persistence $persistenceManager
Результат Neos\Flow\Persistence\PersistenceManagerInterface

$supportedOptions защищенное свойство

Supported options
protected array $supportedOptions
Результат array

$variablesToRender защищенное свойство

Only variables whose name is contained in this array will be rendered
protected array $variablesToRender
Результат array