mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-21 17:54:24 +00:00
set doctrine type "date interval" using native postgresql date interval
This commit is contained in:
parent
0287da70d7
commit
7fb2084506
@ -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(
|
||||
|
27
Doctrine/Type/NativeDateIntervalType.php
Normal file
27
Doctrine/Type/NativeDateIntervalType.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\Doctrine\Type;
|
||||
|
||||
use Doctrine\DBAL\Types\DateIntervalType;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
|
||||
/**
|
||||
* Re-declare the date interval to use the implementation of date interval in
|
||||
* postgreql
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class NativeDateIntervalType extends DateIntervalType
|
||||
{
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return \Doctrine\DBAL\Types\Type::DATEINTERVAL;
|
||||
}
|
||||
|
||||
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
|
||||
{
|
||||
return 'INTERVAL';
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user