TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Extbase\Mvc\View\JsonView Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Mvc\View\JsonView:
TYPO3\CMS\Extbase\Mvc\View\AbstractView TYPO3\CMS\Extbase\Mvc\View\ViewInterface

Public Member Functions

 setVariablesToRender (array $variablesToRender)
 
 setConfiguration (array $configuration)
 
 render ()
 
- Public Member Functions inherited from TYPO3\CMS\Extbase\Mvc\View\AbstractView
 setControllerContext (\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext)
 
 assign ($key, $value)
 
 assignMultiple (array $values)
 
 canRender (\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext)
 
 initializeView ()
 

Public Attributes

const EXPOSE_CLASSNAME_FULLY_QUALIFIED = 1
 
const EXPOSE_CLASSNAME_UNQUALIFIED = 2
 

Protected Member Functions

 renderArray ()
 
 transformValue ($value, array $configuration)
 
 transformObject ($object, array $configuration)
 

Protected Attributes

 $reflectionService
 
 $controllerContext
 
 $variablesToRender = array('value')
 
 $configuration = array()
 
 $persistenceManager
 
- Protected Attributes inherited from TYPO3\CMS\Extbase\Mvc\View\AbstractView
 $controllerContext
 
 $variables = array()
 

Detailed Description

This file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! A JSON view

Definition at line 21 of file JsonView.php.

Member Function Documentation

◆ render()

TYPO3\CMS\Extbase\Mvc\View\JsonView::render ( )

Transforms the value view variable to a serializable array represantion using a YAML view configuration and JSON encodes the result.

Returns
string The JSON encoded variables

Implements TYPO3\CMS\Extbase\Mvc\View\ViewInterface.

Definition at line 191 of file JsonView.php.

References TYPO3\CMS\Extbase\Mvc\View\JsonView\renderArray().

◆ renderArray()

TYPO3\CMS\Extbase\Mvc\View\JsonView::renderArray ( )
protected

Loads the configuration and transforms the value to a serializable array.

Returns
array An array containing the values, ready to be JSON encoded

Definition at line 204 of file JsonView.php.

References TYPO3\CMS\Extbase\Mvc\View\JsonView\$configuration, and TYPO3\CMS\Extbase\Mvc\View\JsonView\transformValue().

Referenced by TYPO3\CMS\Extbase\Mvc\View\JsonView\render().

◆ setConfiguration()

TYPO3\CMS\Extbase\Mvc\View\JsonView::setConfiguration ( array  $configuration)
Parameters
array$configurationThe rendering configuration for this JSON view
Returns
void

Definition at line 179 of file JsonView.php.

References TYPO3\CMS\Extbase\Mvc\View\JsonView\$configuration.

◆ setVariablesToRender()

TYPO3\CMS\Extbase\Mvc\View\JsonView::setVariablesToRender ( array  $variablesToRender)

Specifies which variables this JsonView should render By default only the variable 'value' will be rendered

Parameters
array$variablesToRender
Returns
void

Definition at line 171 of file JsonView.php.

References TYPO3\CMS\Extbase\Mvc\View\JsonView\$variablesToRender.

◆ transformObject()

TYPO3\CMS\Extbase\Mvc\View\JsonView::transformObject (   $object,
array  $configuration 
)
protected

Traverses the given object structure in order to transform it into an array structure.

Parameters
object$objectObject to traverse
array$configurationConfiguration for transforming the given object or NULL
Returns
array Object structure as an array

Definition at line 259 of file JsonView.php.

References TYPO3\CMS\Extbase\Reflection\ObjectAccess\getGettablePropertyNames(), TYPO3\CMS\Extbase\Reflection\ObjectAccess\getProperty(), and TYPO3\CMS\Extbase\Mvc\View\JsonView\transformValue().

Referenced by TYPO3\CMS\Extbase\Mvc\View\JsonView\transformValue().

◆ transformValue()

TYPO3\CMS\Extbase\Mvc\View\JsonView::transformValue (   $value,
array  $configuration 
)
protected

Transforms a value depending on type recursively using the supplied configuration.

Parameters
mixed$valueThe value to transform
array$configurationConfiguration for transforming the value
Returns
array The transformed value

Definition at line 227 of file JsonView.php.

References TYPO3\CMS\Extbase\Mvc\View\JsonView\transformObject().

Referenced by TYPO3\CMS\Extbase\Mvc\View\JsonView\renderArray(), and TYPO3\CMS\Extbase\Mvc\View\JsonView\transformObject().

Member Data Documentation

◆ $configuration

TYPO3\CMS\Extbase\Mvc\View\JsonView::$configuration = array()
protected

◆ $controllerContext

TYPO3\CMS\Extbase\Mvc\View\JsonView::$controllerContext
protected

Definition at line 48 of file JsonView.php.

◆ $persistenceManager

TYPO3\CMS\Extbase\Mvc\View\JsonView::$persistenceManager
protected

Definition at line 161 of file JsonView.php.

◆ $reflectionService

TYPO3\CMS\Extbase\Mvc\View\JsonView::$reflectionService
protected

Definition at line 43 of file JsonView.php.

◆ $variablesToRender

TYPO3\CMS\Extbase\Mvc\View\JsonView::$variablesToRender = array('value')
protected

◆ EXPOSE_CLASSNAME_FULLY_QUALIFIED

const TYPO3\CMS\Extbase\Mvc\View\JsonView::EXPOSE_CLASSNAME_FULLY_QUALIFIED = 1

Definition for the class name exposure configuration, that is, if the class name of an object should also be part of the output JSON, if configured.

Setting this value, the object's class name is fully put out, including the namespace.

Definition at line 31 of file JsonView.php.

Referenced by TYPO3\CMS\Extbase\Tests\Unit\Mvc\View\JsonViewTest\exposeClassNameSettingsAndResults().

◆ EXPOSE_CLASSNAME_UNQUALIFIED

const TYPO3\CMS\Extbase\Mvc\View\JsonView::EXPOSE_CLASSNAME_UNQUALIFIED = 2

Puts out only the actual class name without namespace. See EXPOSE_CLASSNAME_FULL for the meaning of the constant at all.

Definition at line 37 of file JsonView.php.

Referenced by TYPO3\CMS\Extbase\Tests\Unit\Mvc\View\JsonViewTest\exposeClassNameSettingsAndResults().