.. _serialization_handlers: ========= Handlers ========= Serializer handlers take over (de)serialization of a value of given type. T3api delivers handlers for things which are common in TYPO3 but which plain JSON serialization can not handle well - files, processed images, links to records and typolinks. Some handlers are used automatically (based on the class of the value), others are activated by setting the ``type`` of a property or virtual property - with annotation from ``\SourceBroker\T3api\Annotation\Serializer\Type`` namespace or with ``type`` key in :ref:`YAML metadata `. .. list-table:: :header-rows: 1 :widths: 25 35 40 * - Handler - Activated by - Output * - ``FileReferenceHandler`` - automatically for classes extending Extbase's ``FileReference`` or ``Folder`` nested in an entity (on deserialization also ``File`` and its subclasses) - object with ``url``, ``uid`` and ``file`` data * - ``ImageHandler`` - ``@T3api\Serializer\Type\Image``, type ``Image<...>`` - absolute URL of processed image * - ``RecordUriHandler`` - ``@T3api\Serializer\Type\RecordUri``, type ``RecordUri<...>`` - absolute URL of record (e.g. news detail page) * - ``TypolinkHandler`` - ``@T3api\Serializer\Type\Typolink``, type ``Typolink`` - absolute URL built from typolink value * - ``RteHandler`` - ``@T3api\Serializer\Type\Rte``, type ``Rte`` - HTML processed by ``lib.parseFunc_RTE`` * - ``PasswordHashHandler`` - ``@T3api\Serializer\Type\PasswordHash``, type ``PasswordHash`` - on deserialization: hashed password; on serialization: ``null`` (stored hash with ``serialize=true``) * - ``CurrentFeUserHandler`` - ``@T3api\Serializer\Type\CurrentFeUser`` - see :ref:`use-cases_current-user-assignment` .. _serialization_handlers_file-reference: FileReference =============== Objects of classes extending Extbase's ``\TYPO3\CMS\Extbase\Domain\Model\FileReference`` or ``Folder`` (e.g. ``\GeorgRinger\News\Domain\Model\FileReference`` or your own file reference class) nested in an entity are serialized automatically, there is nothing to configure. Objects of classes extending ``File`` are serialized like other objects. Example of ``falMedia`` property of news: .. code-block:: json "falMedia": [ { "url": "https://14.t3api.ddev.site/fileadmin/user_upload/test1.jpg", "uid": 4, "file": { "uid": 1, "name": "test1.jpg", "mimeType": "image/jpeg", "size": 42520 } } ] - ``url`` - absolute URL of the original file. - ``uid`` - uid of the file reference (``sys_file_reference``). - ``file`` - data of the original file (``sys_file``). Contains ``fileToken`` when the token is returned for the file, see :ref:`handling_file_upload_file_token`. - ``urlEmbed`` - only for videos (e.g. YouTube, Vimeo) - URL which can be used in ``