@@ -3,13 +3,12 @@ Implementing a TypedFieldMapper
3
3
4
4
.. versionadded :: 2.14
5
5
6
- You can specify custom typed field mapping between PHP type and DBAL type using ``Configuration ``
6
+ You can specify custom typed field mapping between PHP type and DBAL type using ``Doctrine\ORM\ Configuration ``
7
7
and a custom ``Doctrine\ORM\Mapping\TypedFieldMapper `` implementation.
8
8
9
9
.. code-block :: php
10
10
11
11
<?php
12
-
13
12
$configuration->setTypedFieldMapper(new CustomTypedFieldMapper());
14
13
15
14
@@ -24,6 +23,7 @@ PHP type => DBAL type mappings into its constructor to override the default beha
24
23
<?php
25
24
use App\CustomIds\CustomIdObject;
26
25
use App\DBAL\Type\CustomIdObjectType;
26
+ use Doctrine\ORM\Mapping\DefaultTypedFieldMapper;
27
27
28
28
$configuration->setTypedFieldMapper(new DefaultTypedFieldMapper([
29
29
CustomIdObject::class => CustomIdObjectType::class,
@@ -84,6 +84,7 @@ It is perfectly valid to override even the "automatic" mapping rules mentioned a
84
84
85
85
<?php
86
86
use App\DBAL\Type\CustomIntType;
87
+ use Doctrine\ORM\Mapping\DefaultTypedFieldMapper;
87
88
88
89
$configuration->setTypedFieldMapper(new DefaultTypedFieldMapper([
89
90
'int' => CustomIntType::class,
@@ -126,10 +127,12 @@ the instances were supplied to the ``ChainTypedFieldMapper`` constructor.
126
127
127
128
<?php
128
129
use App\DBAL\Type\CustomIntType;
130
+ use Doctrine\ORM\Mapping\ChainTypedFieldMapper;
131
+ use Doctrine\ORM\Mapping\DefaultTypedFieldMapper;
129
132
130
133
$configuration->setTypedFieldMapper(
131
134
new ChainTypedFieldMapper(
132
- DefaultTypedFieldMapper(['int' => CustomIntType::class,]),
135
+ new DefaultTypedFieldMapper(['int' => CustomIntType::class,]),
133
136
new CustomTypedFieldMapper()
134
137
)
135
138
);
@@ -173,4 +176,4 @@ You need to create a class which implements ``Doctrine\ORM\Mapping\TypedFieldMap
173
176
174
177
Note that this case checks whether the mapping is already assigned, and if yes, it skips it. This is up to your
175
178
implementation. You can make a "greedy" mapper which will always override the mapping with its own type, or one
176
- that behaves like ``DefaultTypedFieldMapper `` and does not modify the type once its set prior in the chain.
179
+ that behaves like the ``DefaultTypedFieldMapper `` and does not modify the type once its set prior in the chain.
0 commit comments