Extbase built-in type converters reference
Extbase selects a type converter automatically based on the PHP type declaration of the action parameter and the shape of the incoming request value. This page lists all converters shipped with TYPO3, their accepted source types, and the configuration constants they expose.
For an introduction to how type converters are selected and configured, see Property mapping: request arguments to objects.
On this page
Simple type converters
These converters handle PHP primitive types and arrays and are selected
automatically whenever an action parameter is typed as
int,
float,
bool,
string, or
array.
IntegerConverter
- Class
-
IntegerConverter - Sources
-
integer,string - Target
-
integer - Priority
-
10
Casts the source value to
int. Returns an error object if the value is
not numeric.
No configuration constants.
FloatConverter
- Class
-
FloatConverter - Sources
-
float,integer,string - Target
-
float - Priority
-
10
Casts the source value to
float. When the source is a string,
thousands separator and decimal point characters can be configured:
FloatConverter:: CONFIGURATION_ THOUSANDS_ SEPARATOR - Character used as the thousands separator in the input string (for
example
'.'for German locale). Default: none. FloatConverter:: CONFIGURATION_ DECIMAL_ POINT - Character used as the decimal separator in the input string (for
example
','for German locale). Default:'.'.
BooleanConverter
- Class
-
BooleanConverter - Sources
-
boolean,string - Target
-
boolean - Priority
-
10
Casts the source value to
bool via a PHP typecast.
No configuration constants.
StringConverter
- Class
-
StringConverter - Sources
-
string,integer - Target
-
string - Priority
-
10
Casts the source value to
string via a PHP typecast.
No configuration constants.
ArrayConverter
- Class
-
ArrayConverter - Sources
-
array,string - Target
-
array - Priority
-
10
Passes an array source unchanged. If the source is a string, splits it on a configurable delimiter:
ArrayConverter:: CONFIGURATION_ DELIMITER - The delimiter character to split the string on. Required when the
source is a non-empty string; throws a
Typeif not set.Converter Exception ArrayConverter:: CONFIGURATION_ REMOVE_ EMPTY_ VALUES - When
true, filters out empty strings after splitting. Default:false. ArrayConverter:: CONFIGURATION_ LIMIT - Maximum number of elements to return (passed as the third argument to
explode). Default:() 0(no limit).
DateTimeConverter
- Class
-
DateTime Converter - Sources
-
string,integer,array - Target
-
Date(orTime Date)Time Immutable - Priority
-
10
Converts a string, Unix timestamp, or array of date parts into a
\Date or
\Date object.
DateTime Converter:: CONFIGURATION_ DATE_ FORMAT - The format string passed to
\Date. Defaults toTime:: create From Format () \Date. Set this if your form sends a date in a locale format (for exampleTime:: W3C 'd.).m. Y'
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Controller;
use MyVendor\MyExtension\Domain\Model\Conference;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter;
class ConferenceController extends ActionController
{
public function initializeCreateAction(): void
{
$this->arguments['conference']
->getPropertyMappingConfiguration()
->forProperty('conferenceDate')
->setTypeConverterOption(
DateTimeConverter::class,
DateTimeConverter::CONFIGURATION_DATE_FORMAT,
'd.m.Y',
);
}
public function createAction(Conference $conference): ResponseInterface
{
// ...
return $this->htmlResponse();
}
}
Object type converters
These converters handle PHP objects and are selected automatically when an
action parameter is typed as a domain object, an enum, or
Object.
PersistentObjectConverter
- Class
-
PersistentObject Converter - Sources
-
integer,string,array - Target
-
Abstract(and subclasses)Domain Object - Priority
-
20
The converter used for domain object parameters. If the source is an integer or plain string, it loads the record with that UID from the repository. If the source is an array, it maps array keys to object properties (and optionally creates or modifies the object):
PersistentObject Converter:: CONFIGURATION_ MODIFICATION_ ALLOWED - Set to
trueto allow property updates on an object that already has a UID. Required when an array payload includes an__identitykey alongside changed properties. PersistentObject Converter:: CONFIGURATION_ CREATION_ ALLOWED - Set to
trueto allow creating a new object from an array payload that carries no__identitykey.
Both constants default to
false. When a __trustedProperties
token is present (generated by
<f:), Extbase enables or disables
them automatically based on whether an __identity field was rendered.
ObjectConverter
- Class
-
ObjectConverter - Sources
-
array - Target
-
object - Priority
-
10
Creates a plain (non-persistent) PHP object from an array of constructor
arguments or property values. Used for value objects and
DTO classes that do not extend
Abstract.
ObjectConverter:: CONFIGURATION_ TARGET_ TYPE - Override the concrete class to instantiate (must be a subclass of the declared target type).
ObjectConverter:: CONFIGURATION_ OVERRIDE_ TARGET_ TYPE_ ALLOWED - Set to
trueto permit theCONFIGURATION_override. Disabled by default as a security measure.TARGET_ TYPE
ObjectStorageConverter
- Class
-
ObjectStorage Converter - Sources
-
string,array - Target
-
ObjectStorage - Priority
-
10
Converts an array (or comma-separated string) into an
Object. Each element is
converted individually using the converter registered for the storage's
generic type.
No configuration constants.
EnumConverter
- Class
-
EnumConverter - Sources
-
string,integer,float - Target
-
object(any\Unitsubclass)Enum - Priority
-
20
New in version 14.0
Converts a scalar value to a PHP backed enum case. For backed enums the
source value is matched against the
value of each case. For pure
(unit) enums it is matched against the case
name.
No configuration constants.
TYPO3 Core type converters
These converters handle TYPO3-specific types and are selected automatically for the relevant action parameters.
CoreTypeConverter
- Class
-
CoreType Converter - Sources
-
string,integer,float,boolean,array - Target
-
TypeInterface - Priority
-
10
Handles TYPO3 Core value types that implement
Type, such as
\Enumeration subclasses.
No configuration constants.
CountryConverter
- Class
-
CountryConverter - Sources
-
string - Target
-
Country - Priority
-
10
Looks up a
Country object by ISO code.
Defaults to matching alpha-2 codes (for example
'DE'):
CountryConverter:: CONFIGURATION_ FROM -
How to match the source string. Accepted values:
'alpha2Iso(default) — two-letter ISO 3166-1 alpha-2 code.Code' 'alpha3Iso— three-letter ISO 3166-1 alpha-3 code.Code'
FAL type converters
Warning
These three converter classes are
@internal at the class level
and are not part of the public Extbase API. Their behaviour or existence
may change without notice.
FileConverter - Converts an integer (file UID) or string to a
Fileobject. FileReference Converter - Converts an integer (file reference UID) to a
Fileobject.Reference FolderConverter - Converts a string (folder combined identifier) to a
Folderobject.
Writing a custom type converter
There are no PHP attributes for registering type converters. Registration
requires an
extbase. service tag in
Configuration/Services.yaml.
Implement
Type (or extend
Abstract).
Then register it via a service tag in Configuration/Services.yaml:
namespace MyVendor\MyExtension\Property\TypeConverter;
use TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface;
use TYPO3\CMS\Extbase\Property\TypeConverter\AbstractTypeConverter;
class IsbnConverter extends AbstractTypeConverter
{
public function convertFrom(
$source,
string $targetType,
array $convertedChildProperties = [],
?PropertyMappingConfigurationInterface $configuration = null,
): mixed {
// return the converted value or a \TYPO3\CMS\Extbase\Error\Error instance
}
}
MyVendor\MyExtension\Property\TypeConverter\IsbnConverter:
tags:
- name: extbase.type_converter
priority: 10
target: MyVendor\MyExtension\Domain\Model\Isbn
sources: string
The
priority determines which converter wins when multiple converters
match the same source-and-target combination. Higher numbers win.