8000 [DoctrineBridge] DatePoint type · Issue #59889 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DoctrineBridge] DatePoint type #59889

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

Closed
garak opened this issue Mar 1, 2025 · 3 comments · Fixed by #59900
Closed

[DoctrineBridge] DatePoint type #59889

garak opened this issue Mar 1, 2025 · 3 comments · Fixed by #59900
Labels
DoctrineBridge Feature Help wanted Issues and PRs which are looking for volunteers to complete them.

Comments

@garak
Copy link
Contributor
garak commented Mar 1, 2025

Description

DatePoint was introduced in Symfony 6.4, but it's still impossible to use in a Doctrine entity, since it lacks a dedicated Doctrine type.
It would be nice to get the type in the Doctrine bridge, similar to the already available UuidType and UlidType

Example

No response

@nicolas-grekas
Copy link
Member

Definitely!
Help wanted!

@nicolas-grekas nicolas-grekas added the Help wanted Issues and PRs which are looking for volunteers to complete them. label Mar 1, 2025
@GromNaN
Copy link
Member
GromNaN commented Mar 1, 2025

@garak Do you want to open a PR?

The new type class Symfony\Bridge\Doctrine\Types\DatePointType can extend Doctrine\DBAL\Types\DateTimeImmutableType and override convertToPHPValue.

    public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?DatePoint
    {
        $value = $this->convertToPHPValue($value, $platform);

        if ($value instanceof DateTimeInterface) {
            return DatePoint::createFromInterface($value);
        }

        return $value;
    }

Then a new RegisterDatePointTypePass can be added.


But I think this could be improved in a more generic way in Doctrine ORM: it could detect the expected class and convert to it automatically.

@ksn135
Copy link
ksn135 commented May 17, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DoctrineBridge Feature Help wanted Issues and PRs which are looking for volunteers to complete them.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
0