Adds the EnumConverter into TYPO3 11.
[FEATURE] Add TypeConverter for enums
With PHP 8.1 we got Enums, to use them also in our extbase actions, a new TypeConverter is added with this patch.
The EnumConverter is automatically used if the target type is an enum.
composer req andersundsehr/extbase_enum_converter
With PHP 8.1 we got Enums to use them also in our extbase actions,
a new TypeConverter was added with this feature. \TYPO3\CMS\Extbase\Property\TypeConverter\EnumConverter
Given an enum like this one:
enum ClosedStates
{
case hide;
case show;
case all;
}
We can now use it like this in any extbase action:
public function overviewAction(ClosedStates $closed = ClosedStates::hide): ResponseInterface
{
The URL argument can be send as [closed]=show
and is automatically converted to an instance of ClosedStates::show
Enums can now be used as extbase action arguments.
If something did not work 😮
or you appreciate this Extension 🥰 let us know.
We are hiring https://www.andersundsehr.com/karriere/