PHP 클래스 Neos\Flow\Mvc\View\JsonView

상속: extends AbstractView
파일 보기 프로젝트 열기: neos/flow-development-collection 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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