Configuration¶
Overview¶
The configuration is made for each class property. You must specify the full class path, and then configure which properties should be output.
Classes and configurations of their output properties are configured in
plugin.tx_pxadataprovider.objectConfig
. In this example, we’re
configuring TYPO3\CMS\Extbase\DomainObject\AbstractEntity
.
plugin.tx_pxadataprovider { settings { objectConfig { TYPO3\CMS\Extbase\DomainObject\AbstractEntity { key = entity includeProperties = uid,pid,_timestamp excludeProperties = pid remapProperties { uid = id } processProperties { _timestamp { data = date : c } } } } } }
Class inheritance¶
Configurations for one class is inherited to the class’ children. In the
example above, the configuration will be applied to every descendant class
of TYPO3\CMS\Extbase\DomainObject\AbstractEntity
, such as
TYPO3\CMS\Extbase\Domain\Model\FrontendUser
or really any entity class
within an Extbase extension.
You can override configurations by specifying configurations for a descendant. Take this configuration as an example:
objectConfig { TYPO3\CMS\Extbase\DomainObject\AbstractEntity { key = entity includeProperties = uid } TYPO3\CMS\Extbase\Domain\Model\FrontendUser { key = user includeProperties = name } }
When outputting TYPO3\CMS\Extbase\Domain\Model\FrontendUser
object data,
the configuration used will be
key = user includeProperties = uid,name
As you can see, the includeProperties
property includes both uid
and name properties.
What is a Property?¶
You will often think of properties as being database fields, but they are
really any class property accessible through a $object->getProperty()
or
$object->isProperty()
call.
In the example above, the data will be retrieved by calling
- For name:
$object->getName()
(if it exists) or alternately$object->isName()
(if it exists).- For name:
$object->getUid()
(if it exists) or alternately$object->isName()
(if it exists).
If neither $object->getProperty()
nor
$object->isProperty()
exists, the value will be returned as null
.
Class Configuration Options¶
The options are listed in the order of execution.
key¶
- Property
- key
- Data type
- string
- Description
- The name used for the container of output data for objects of this class.
Example
TYPO3\CMS\Extbase\Domain\Model\FrontendUser { key = user }If the object
{userObject}
is of classTYPO3\CMS\Extbase\Domain\Model\FrontendUser
or a descendant class, this Fluid template:<dp:provider.json object="{userObject}" />Will output JSON (formatting added):
{ "user": [ { "uid": 123, "name": "John Doe" } ] }
includeProperties¶
- Property
- includeProperties
- Data type
- string (comma-separated values)
- Description
- The properties to be output.
Example
includeProperties = uid,name
excludeProperties¶
- Property
- excludeProperties
- Data type
- string (comma-separated values)
- Description
- Properties explicitly to be removed from output.
Example
excludeProperties = password,passwordHint
remapProperties¶
- Property
- remapProperties
- Data type
- Array of properties and their new names
- Description
- Properties explicitly to be removed from output.
Example
This will output the value of the property uid under the property name id.
remapProperties { uid = id }
processProperties¶
- Property
- processProperties
- Data type
- Array of property names and stdWrap processing instructions.
- Description
- Use stdWrap to modify property values before output. You can also use this configuration to generate new properties
Example
This will output the value of the property uid under the property name id.
remapProperties { name { wrap = <name>|</name> } _timestamp { data = date : c } }Will output JSON (formatting added):
{ "user": [ { "name": "<name>John Doe</name>", "_timestamp": "2020-01-24T12:40:51+00:00" } ] }