mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-3153: DoctrineObject Hydrator - handleTypeConversion interfers with date strategies #3912
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Jun 5, 2014).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user Qronicle:
We would like to add a strategy for date properties. (So that we have automatic conversion to a \DateTime object after saving a form.)
The DoctrineObject hydrator tries to do this automatically with the handleTypeConversions method, which converts a string in a date property to a \DateTime object. Problem here is that the input format is not always the expected format for this conversion, so an exception is thrown.
We've made a DateTime strategy that converts the value to a \DateTime object with a defined format.
Problem: The handleTypeConversions method is called before the strategy is invoked, thus we get the datetime conversion exception.
Solution: We have overridden the DoctrineObject hydrator for now, and only execute the handleTypeConversions after the strategy:
I don't know if this is the best solution, but it works for us, anyway.
@doctrinebot commented on GitHub (Jun 6, 2014):
Comment created by @ocramius:
This bug should be reported at https://github.com/doctrine/DoctrineModule, as it doesn't affect the core ORM
@doctrinebot commented on GitHub (Jun 6, 2014):
Issue was closed with resolution "Can't Fix"
@doctrinebot commented on GitHub (Jun 6, 2014):
Comment created by Qronicle:
Will do, thanks for pointing me in the right direction!