Permalink
Browse files

feature #22689 [DoctrineBridge] Add support for doctrin/dbal v2.6 typ…

…es (jvasseur)

This PR was merged into the 3.4 branch.

Discussion
----------

[DoctrineBridge] Add support for doctrin/dbal v2.6 types

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

Add support for the following doctrine types in the property info extractor:
 - date_immutable
 - datetime_immutable
 - datetimetz_immutable
 - time_immutable
 - dateinterval

I didn't include the json type since it can be anything that can be stored in a json.

And add support for the dateinterval type for the form type guesser (the form component doesn't support using DateTimeImmutable instances).

Commits
-------

b30fd4f Add support for doctrin/dbal 2.6 types
  • Loading branch information...
nicolas-grekas committed Jul 12, 2017
2 parents c8f2c96 + b30fd4f commit 3b2f9fb89ad9b3c63ad9918c4c43e0d2aa73b6e6
@@ -1,6 +1,11 @@
CHANGELOG
=========
3.4.0
-----
* added support for doctrine/dbal v2.6 types
3.1.0
-----
@@ -60,6 +60,8 @@ public function guessType($class, $property)
case Type::DATETIMETZ:
case 'vardatetime':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', array(), Guess::HIGH_CONFIDENCE);
case 'dateinterval':
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateIntervalType', array(), Guess::HIGH_CONFIDENCE);
case Type::DATE:
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', array(), Guess::HIGH_CONFIDENCE);
case Type::TIME:
@@ -117,6 +117,15 @@ public function getTypes($class, $property, array $context = array())
case DBALType::TIME:
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTime'));
case 'date_immutable':
case 'datetime_immutable':
case 'datetimetz_immutable':
case 'time_immutable':
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTimeImmutable'));
case 'dateinterval':
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateInterval'));
case DBALType::TARRAY:
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true));
@@ -48,6 +48,8 @@ public function testGetProperties()
'id',
'guid',
'time',
'timeImmutable',
'dateInterval',
'json',
'simpleArray',
'float',
@@ -78,6 +80,9 @@ public function typesProvider()
array('id', array(new Type(Type::BUILTIN_TYPE_INT))),
array('guid', array(new Type(Type::BUILTIN_TYPE_STRING))),
array('bigint', array(new Type(Type::BUILTIN_TYPE_STRING))),
array('time', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))),
array('timeImmutable', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeImmutable'))),
array('dateInterval', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateInterval'))),
array('float', array(new Type(Type::BUILTIN_TYPE_FLOAT))),
array('decimal', array(new Type(Type::BUILTIN_TYPE_STRING))),
array('bool', array(new Type(Type::BUILTIN_TYPE_BOOL))),
@@ -55,6 +55,16 @@ class DoctrineDummy
*/
private $time;
/**
* @Column(type="time_immutable")
*/
private $timeImmutable;
/**
* @Column(type="dateinterval")
*/
private $dateInterval;
/**
* @Column(type="json_array")
*/

0 comments on commit 3b2f9fb

Please sign in to comment.