New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EntityRoute does not support enum fields #17473
Comments
Additionaly RouteBuilder could also get some Enum support. Currently i need to make enum routes like this: $builder->connect(
'/create/{sharing_type}/ipv6',
['action' => 'add', 'ip_version' => IpVersion::IPv6->value],
['sharing_type' => implode('|', array_column(SharingType::cases(), 'value'))]
);
$builder->connect(
'/create/{sharing_type}/',
['action' => 'add', 'ip_version' => IpVersion::IPv4->value],
['sharing_type' => implode('|', array_column(SharingType::cases(), 'value'))]
); native support for enums in routing logic itself this could allow this example to trimmed down to: $builder->connect(
'/create/{sharing_type}/ipv6',
['action' => 'add', 'ip_version' => IpVersion::IPv6],
['sharing_type' => SharingType::cases()]
);
$builder->connect(
'/create/{sharing_type}/',
['action' => 'add', 'ip_version' => IpVersion::IPv4],
['sharing_type' => SharingType::cases()]
); |
Do you want to make a PR for 5.next to add support for this? |
Bumping to 5.1 as we haven't implemented enum support into routes yet, so it isn't a defect. I do agree that it is a useful addition 😄 |
This issue is stale because it has been open for 120 days with no activity. Remove the |
Description
I don't know is this ticket should be classified as bug or as feature request (kinda both)
Currently,
EntityRoute
simply does not work with\BackedEnum
fields as expected.For purpose of routing
\StringBackedEnum
values should be casted to strings and\IntBackedEnum
values should be casted to intsI currently already do this in my
CustomEntityRoute
class but i feel this should be part of the base CakePHPCakePHP Version
5.x
PHP Version
No response
The text was updated successfully, but these errors were encountered: