You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, implement a new type by extending `Doctrine\DBAL\Types\Type`. An example can be found in
25
+
the `ORM cookbook <https://www.doctrine-project.org/projects/doctrine-orm/en/current/cookbook/custom-mapping-types.html#custom-mapping-types>`__
26
+
Then, register your type implementation with DBAL as follows:
44
27
45
28
.. code:: php
46
29
@@ -49,48 +32,35 @@ How to add a new type
49
32
'configuration' => [
50
33
'orm_default' => [
51
34
'types' => [
52
-
'newtype' => 'Db\DBAL\Types\NewType',
35
+
'newtype' => \My\Types\NewType::class,
53
36
],
54
37
],
55
38
],
56
39
],
57
40
];
58
41
59
-
.. code:: php
60
-
61
-
return [
62
-
'doctrine' => [
63
-
'connection' => [
64
-
'orm_default' => [
65
-
'doctrine_type_mappings' => [
66
-
'mytype' => 'mytype',
67
-
],
68
-
],
69
-
],
70
-
],
71
-
];
42
+
.. note::
72
43
44
+
If your type uses a database type which is already `mapped by Doctrine <https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#mapping-matrix>`__,
45
+
Doctrine will need a comment hint to distinguish your type from other types. In your type class, override
46
+
`requiresSQLCommentHint()` to return `true` to let Doctrine add a comment hint.
73
47
74
-
Doctrine Type Comment
75
-
---------------------
76
-
77
-
Option to set the doctrine type comment (DC2Type:myType) for custom types
48
+
Next, you will need to register your custom type with the underlying database platform:
78
49
79
50
.. code:: php
80
51
81
52
return [
82
53
'doctrine' => [
83
54
'connection' => [
84
55
'orm_default' => [
85
-
'doctrineCommentedTypes' => [
86
-
'mytype',
56
+
'doctrine_type_mappings' => [
57
+
'mytype' => 'mytype',
87
58
],
88
59
],
89
60
],
90
61
],
91
62
];
92
63
93
-
94
64
Built-in Resolver
95
65
-----------------
96
66
@@ -103,8 +73,8 @@ How to Define Relationships with Abstract Classes and Interfaces (ResolveTargetE
0 commit comments