Feature: #98171 - Add Extbase TypeConverter for enums¶
See forge#98171
Description¶
Since PHP 8.1 provides enums, we can also use them in our Extbase actions.
A new TypeConverter
\TYPO3\CMS\Extbase\Property\TypeConverter\EnumConverter
was added with this feature.
Example¶
Given an enum like this one:
enum ClosedStates
{
case Hide;
case Show;
case All;
}
Copied!
We can now use it like this in any Extbase action:
public function overviewAction(ClosedStates $closed = ClosedStates::Hide): ResponseInterface
{
// ...
}
Copied!
The URL argument can be send as [closed]=Show
and is automatically converted
to an instance of ClosedStates::Show
Impact¶
Enums can now be used as Extbase action arguments.