Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3b2f9fb

Browse filesBrowse files
feature #22689 [DoctrineBridge] Add support for doctrin/dbal v2.6 types (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
2 parents c8f2c96 + b30fd4f commit 3b2f9fb
Copy full SHA for 3b2f9fb

File tree

5 files changed

+31
-0
lines changed
Filter options

5 files changed

+31
-0
lines changed

‎src/Symfony/Bridge/Doctrine/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
3.4.0
5+
-----
6+
7+
* added support for doctrine/dbal v2.6 types
8+
49
3.1.0
510
-----
611

‎src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public function guessType($class, $property)
6060
case Type::DATETIMETZ:
6161
case 'vardatetime':
6262
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateTimeType', array(), Guess::HIGH_CONFIDENCE);
63+
case 'dateinterval':
64+
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateIntervalType', array(), Guess::HIGH_CONFIDENCE);
6365
case Type::DATE:
6466
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\DateType', array(), Guess::HIGH_CONFIDENCE);
6567
case Type::TIME:

‎src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ public function getTypes($class, $property, array $context = array())
117117
case DBALType::TIME:
118118
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTime'));
119119

120+
case 'date_immutable':
121+
case 'datetime_immutable':
122+
case 'datetimetz_immutable':
123+
case 'time_immutable':
124+
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTimeImmutable'));
125+
126+
case 'dateinterval':
127+
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateInterval'));
128+
120129
case DBALType::TARRAY:
121130
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true));
122131

‎src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public function testGetProperties()
4848
'id',
4949
'guid',
5050
'time',
51+
'timeImmutable',
52+
'dateInterval',
5153
'json',
5254
'simpleArray',
5355
'float',
@@ -78,6 +80,9 @@ public function typesProvider()
7880
array('id', array(new Type(Type::BUILTIN_TYPE_INT))),
7981
array('guid', array(new Type(Type::BUILTIN_TYPE_STRING))),
8082
array('bigint', array(new Type(Type::BUILTIN_TYPE_STRING))),
83+
array('time', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))),
84+
array('timeImmutable', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeImmutable'))),
85+
array('dateInterval', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateInterval'))),
8186
array('float', array(new Type(Type::BUILTIN_TYPE_FLOAT))),
8287
array('decimal', array(new Type(Type::BUILTIN_TYPE_STRING))),
8388
array('bool', array(new Type(Type::BUILTIN_TYPE_BOOL))),

‎src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ class DoctrineDummy
5555
*/
5656
private $time;
5757

58+
/**
59+
* @Column(type="time_immutable")
60+
*/
61+
private $timeImmutable;
62+
63+
/**
64+
* @Column(type="dateinterval")
65+
*/
66+
private $dateInterval;
67+
5868
/**
5969
* @Column(type="json_array")
6070
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.