mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
fix date interval storage
This commit is contained in:
parent
395787f1bb
commit
5693091591
@ -14,6 +14,7 @@ use Doctrine\DBAL\Types\ConversionException;
|
|||||||
*/
|
*/
|
||||||
class NativeDateIntervalType extends DateIntervalType
|
class NativeDateIntervalType extends DateIntervalType
|
||||||
{
|
{
|
||||||
|
const FORMAT = '%rP%YY%MM%DDT%HH%IM%SS';
|
||||||
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
@ -25,6 +26,22 @@ class NativeDateIntervalType extends DateIntervalType
|
|||||||
return 'INTERVAL';
|
return 'INTERVAL';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function convertToDatabaseValue($value, AbstractPlatform $platform)
|
||||||
|
{
|
||||||
|
if (null === $value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($value instanceof \DateInterval) {
|
||||||
|
return $value->format(self::FORMAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw ConversionException::conversionFailedInvalidType($value, $this->getName(), ['null', 'DateInterval']);
|
||||||
|
}
|
||||||
|
|
||||||
public function convertToPHPValue($value, AbstractPlatform $platform)
|
public function convertToPHPValue($value, AbstractPlatform $platform)
|
||||||
{
|
{
|
||||||
if ($value === null || $value instanceof \DateInterval) {
|
if ($value === null || $value instanceof \DateInterval) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user