TYPO3 CMS  TYPO3_7-6
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

 injectPersistenceManager (\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface $persistenceManager)
 
 injectReflectionService (\TYPO3\CMS\Extbase\Reflection\ReflectionService $reflectionService)
 
 setVariablesToRender (array $variablesToRender)
 
 setConfiguration (array $configuration)
 
- 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 Member Functions inherited from TYPO3\CMS\Extbase\Mvc\View\ViewInterface
 render ()
 

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 = ['value']
 
 $configuration = []
 
 $persistenceManager
 
- Protected Attributes inherited from TYPO3\CMS\Extbase\Mvc\View\AbstractView
 $controllerContext
 
 $variables = []
 

Detailed Description

A JSON view

Definition at line 25 of file JsonView.php.

Member Function Documentation

◆ injectPersistenceManager()

TYPO3\CMS\Extbase\Mvc\View\JsonView::injectPersistenceManager ( \TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface  $persistenceManager)
Parameters
\TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface$persistenceManager

Definition at line 168 of file JsonView.php.

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

◆ injectReflectionService()

TYPO3\CMS\Extbase\Mvc\View\JsonView::injectReflectionService ( \TYPO3\CMS\Extbase\Reflection\ReflectionService  $reflectionService)
Parameters
\TYPO3\CMS\Extbase\Reflection\ReflectionService$reflectionService

Definition at line 176 of file JsonView.php.

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

◆ 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 244 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\setConfiguration().

◆ setConfiguration()

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

Definition at line 198 of file JsonView.php.

References TYPO3\CMS\Extbase\Mvc\View\JsonView\$configuration, $GLOBALS, TYPO3\CMS\Extbase\Mvc\View\ViewInterface\render(), and TYPO3\CMS\Extbase\Mvc\View\JsonView\renderArray().

◆ 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 189 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 301 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 268 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 = []
protected

◆ $controllerContext

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

Definition at line 51 of file JsonView.php.

◆ $persistenceManager

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

◆ $reflectionService

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

◆ $variablesToRender

TYPO3\CMS\Extbase\Mvc\View\JsonView::$variablesToRender = ['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 35 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 41 of file JsonView.php.

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