Skip to content

[DoctrineBridge] Expose property type in Form/ChoiceList/IdReader #62303

@pluk77

Description

@pluk77

Description

The IdReader currently does not expose the actual property type, only the fact that it is an integer or not.

As binary UUID values are more and more used as identifiiers, why not expose the actual type so users of this reader can use that to determine if the value should be converted or not?

The constructor already call this:

'$idType = $classMetadata->getTypeOfField(current($ids));'

so why not store this in a property and expose it via

public function getIdType(): string

Shall I create a PR for this?

Example

EasyAdmin makes use of this idReader but has no access to the actual type, only that it is not an integer.

see: https://github.com/EasyCorp/EasyAdminBundle/pull/7210/files

It would be so much easier if a conversion could be attempted based on the return value of getIdType() instead of isIntId()

if (false === $options['id_reader']->isIntId()) {
                $data['autocomplete'] = array_map(
                    fn ($v) => Ulid::isValid($v) ? Ulid::fromBase32($v)->toRfc4122() : $v,
                    $data['autocomplete']
                );
            }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions