PHP Класс FluidTYPO3\Vhs\ViewHelpers\Format\Json\EncodeViewHelper

Returns a string containing the JSON representation of the argument. The argument may be any of the following types: - arrays, associative and traditional - DomainObjects - arrays containing DomainObjects - ObjectStorage containing DomainObjects - standard types (string, integer, boolean, float, NULL) - DateTime including ones found as property values on DomainObjects Recursion protection is enabled for DomainObjects with the option to add a special marker (any variable type above also supported here) which is inserted where an object which would cause recursion would be placed. Be specially careful when you JSON encode DomainObjects which have recursive relations to itself using either 1:n or m:n - in this case the one member of the converted relation will be whichever value you specified as "recursionMarker" - or the default value, NULL. When using the output of such conversion in JavaScript please make sure you check the type before assuming that every member of a converted 1:n or m:n recursive relation is in fact a JavaScript. Not doing so may result in fatal JavaScript errors in the client browser.
Автор: Claus Due ([email protected])
Наследование: extends TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
Показать файл Открыть проект

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

Свойство Тип Описание
$encounteredClasses array

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

Метод Описание
render ( mixed $value = null, boolean $useTraversableKeys = false, boolean $preventRecursion = true, mixed $recursionMarker = null, string $dateTimeFormat = null ) : string

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

Метод Описание
dateTimeToUnixtimeMiliseconds ( DateTime $dateTime, string $dateTimeFormat ) : integer Formats a single DateTime instance to whichever value is demanded by the format specified in $dateTimeFormat (DateTime::format syntax).
encodeValue ( string $value, boolean $useTraversableKeys, boolean $preventRecursion, string $recursionMarker, string $dateTimeFormat ) : mixed
recursiveArrayOfDomainObjectsToArray ( array $domainObjects, boolean $preventRecursion, mixed $recursionMarker ) : array Convert an array of possible DomainObject instances. The argument $possibleDomainObjects could also an associative array representation of another DomainObject - which means each value could potentially be another DomainObject, an ObjectStorage of DomainObjects or a simple value type. The type is checked and another recursive call is used to convert any nested objects.
recursiveDateTimeToUnixtimeMiliseconds ( array $array, string $dateTimeFormat ) : array Converts any encountered DateTime instances to UNIXTIME timestamps which are then multiplied by 1000 to create a JavaScript appropriate time stamp - ready to be loaded into a Date object client-side.
recursiveDomainObjectToArray ( TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $domainObject, boolean $preventRecursion, mixed $recursionMarker ) : array Convert a single DomainObject instance first to an array, then pass that array through recursive DomainObject detection. This will convert any 1:1, 1:n, n:1 and m:n relations.

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

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

Default format is NULL a JS UNIXTIME (time()*1000) is produced.
protected dateTimeToUnixtimeMiliseconds ( DateTime $dateTime, string $dateTimeFormat ) : integer
$dateTime DateTime
$dateTimeFormat string
Результат integer

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

protected encodeValue ( string $value, boolean $useTraversableKeys, boolean $preventRecursion, string $recursionMarker, string $dateTimeFormat ) : mixed
$value string
$useTraversableKeys boolean
$preventRecursion boolean
$recursionMarker string
$dateTimeFormat string
Результат mixed

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

Convert an array of possible DomainObject instances. The argument $possibleDomainObjects could also an associative array representation of another DomainObject - which means each value could potentially be another DomainObject, an ObjectStorage of DomainObjects or a simple value type. The type is checked and another recursive call is used to convert any nested objects.
protected recursiveArrayOfDomainObjectsToArray ( array $domainObjects, boolean $preventRecursion, mixed $recursionMarker ) : array
$domainObjects array
$preventRecursion boolean
$recursionMarker mixed
Результат array

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

Works on already converted DomainObjects which are at this point just associative arrays of values - which might be DateTime instances.
protected recursiveDateTimeToUnixtimeMiliseconds ( array $array, string $dateTimeFormat ) : array
$array array
$dateTimeFormat string
Результат array

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

Convert a single DomainObject instance first to an array, then pass that array through recursive DomainObject detection. This will convert any 1:1, 1:n, n:1 and m:n relations.
protected recursiveDomainObjectToArray ( TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $domainObject, boolean $preventRecursion, mixed $recursionMarker ) : array
$domainObject TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface
$preventRecursion boolean
$recursionMarker mixed
Результат array

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

public render ( mixed $value = null, boolean $useTraversableKeys = false, boolean $preventRecursion = true, mixed $recursionMarker = null, string $dateTimeFormat = null ) : string
$value mixed Array or Traversable
$useTraversableKeys boolean If TRUE, preserves keys from Traversables converted to arrays. Not recommended for ObjectStorages!
$preventRecursion boolean If FALSE, allows recursion to occur which could potentially be fatal to the output unless managed
$recursionMarker mixed Any value - string, integer, boolean, object or NULL - inserted instead of recursive instances of objects
$dateTimeFormat string A date() format for converting DateTime values to JSON-compatible values. NULL means JS UNIXTIME (time()*1000)
Результат string

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

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

protected array $encounteredClasses
Результат array