Document core TypeInterface
mbrodala opened this issue · 1 comments
mbrodala commented
The \TYPO3\CMS\Core\Type\TypeInterface
is extremely useful in Extbase to encapsulate raw data in model properties.
The basic facts:
- When using a custom class (which implements
TypeInterface
) as property type, the class will get the raw value as constructor argument while mapping - Since
TypeInterface
dictates implementation of__toString()
, the wrapped raw value is converted to string when persisting the model.
By default this is used in Extbase to handle custom Enumeration
classes but any arbitrary custom class works just as fine.
An example for using this is loading and storing JSON data. In the database this would be stored as string, a custom TypeInterface
class could unserialize and enrich this for usage on runtime. Saving changes is as simple as serializing the runtime value again.
DanielSiepmann commented
The PR was already merged.