Skip to content

Commit 08ba8f1

Browse files
committed
Improve and fix TypedFieldMapper docs
1 parent 30a2680 commit 08ba8f1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

docs/en/reference/typedfieldmapper.rst

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ Implementing a TypedFieldMapper
33

44
.. versionadded:: 2.14
55

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``
77
and a custom ``Doctrine\ORM\Mapping\TypedFieldMapper`` implementation.
88

99
.. code-block:: php
1010
1111
<?php
12-
1312
$configuration->setTypedFieldMapper(new CustomTypedFieldMapper());
1413
1514
@@ -24,6 +23,7 @@ PHP type => DBAL type mappings into its constructor to override the default beha
2423
<?php
2524
use App\CustomIds\CustomIdObject;
2625
use App\DBAL\Type\CustomIdObjectType;
26+
use Doctrine\ORM\Mapping\DefaultTypedFieldMapper;
2727
2828
$configuration->setTypedFieldMapper(new DefaultTypedFieldMapper([
2929
CustomIdObject::class => CustomIdObjectType::class,
@@ -84,6 +84,7 @@ It is perfectly valid to override even the "automatic" mapping rules mentioned a
8484
8585
<?php
8686
use App\DBAL\Type\CustomIntType;
87+
use Doctrine\ORM\Mapping\DefaultTypedFieldMapper;
8788
8889
$configuration->setTypedFieldMapper(new DefaultTypedFieldMapper([
8990
'int' => CustomIntType::class,
@@ -126,10 +127,12 @@ the instances were supplied to the ``ChainTypedFieldMapper`` constructor.
126127
127128
<?php
128129
use App\DBAL\Type\CustomIntType;
130+
use Doctrine\ORM\Mapping\ChainTypedFieldMapper;
131+
use Doctrine\ORM\Mapping\DefaultTypedFieldMapper;
129132
130133
$configuration->setTypedFieldMapper(
131134
new ChainTypedFieldMapper(
132-
DefaultTypedFieldMapper(['int' => CustomIntType::class,]),
135+
new DefaultTypedFieldMapper(['int' => CustomIntType::class,]),
133136
new CustomTypedFieldMapper()
134137
)
135138
);
@@ -173,4 +176,4 @@ You need to create a class which implements ``Doctrine\ORM\Mapping\TypedFieldMap
173176

174177
Note that this case checks whether the mapping is already assigned, and if yes, it skips it. This is up to your
175178
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

Comments
 (0)