From 7fb208450620914df0e909cb67cace0e5672605b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 16 Apr 2018 11:53:39 +0200 Subject: [PATCH] set doctrine type "date interval" using native postgresql date interval --- DependencyInjection/ChillMainExtension.php | 9 ++++++++ Doctrine/Type/NativeDateIntervalType.php | 27 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Doctrine/Type/NativeDateIntervalType.php diff --git a/DependencyInjection/ChillMainExtension.php b/DependencyInjection/ChillMainExtension.php index c2f63761f..7a5766d4c 100644 --- a/DependencyInjection/ChillMainExtension.php +++ b/DependencyInjection/ChillMainExtension.php @@ -141,6 +141,15 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, ) )); + //add dbal types (default entity_manager) + $container->prependExtensionConfig('doctrine', array( + 'dbal' => [ + 'types' => [ + 'dateinterval' => \Chill\MainBundle\Doctrine\Type\NativeDateIntervalType::class + ] + ] + )); + //add current route to chill main $container->prependExtensionConfig('chill_main', array( 'routing' => array( diff --git a/Doctrine/Type/NativeDateIntervalType.php b/Doctrine/Type/NativeDateIntervalType.php new file mode 100644 index 000000000..06143f229 --- /dev/null +++ b/Doctrine/Type/NativeDateIntervalType.php @@ -0,0 +1,27 @@ + + */ +class NativeDateIntervalType extends DateIntervalType +{ + + public function getName(): string + { + return \Doctrine\DBAL\Types\Type::DATEINTERVAL; + } + + public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string + { + return 'INTERVAL'; + } + +}