Skip to content

Commit 217a850

Browse files
committed
Add upgrade instructions
1 parent 6c01907 commit 217a850

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

UPGRADE-2.16.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ Calling `Doctrine\ODM\MongoDB\Configuration::setProxyDir()` or
4747
`Doctrine\ODM\MongoDB\Configuration::getProxyDir()` is deprecated and triggers
4848
a deprecation notice when using native lazy objects.
4949

50+
## `TypeRegistry` replace `Type::getType()` and `Type::hasType()`
51+
52+
A new `Doctrine\ODM\MongoDB\Types\TypeRegistry` class has been introduced
53+
to manage custom types. The static methods of `Doctrine\ODM\MongoDB\Types\Type`
54+
are deprecated and will be removed in MongoDB ODM 3.0:
55+
- `Type::getType($name)``TypeRegistry::getType($name)`
56+
- `Type::hasType($name)``TypeRegistry::hasType($name)`
57+
- `Type::addType($name, $class)``TypeRegistry::addType($name, $class)`
58+
- `Type::getTypesMap()``TypeRegistry::getTypesMap()`
59+
- `Type::registerType()``TypeRegistry::registerType()`
60+
- `Type::overrideType()``TypeRegistry::registerType()`
61+
- `Type::getTypeFromPHPVariable()``TypeRegistry::guessTypeFromValue()`
62+
- 'Type::convertPHPToDatabaseValue()``TypeRegistry::convertToDatabaseValue()`'
63+
64+
You can set and get the `TypeRegistry` instance from the `Doctrine\ODM\MongoDB\Configuration`
65+
using `getTypeRegistry()` and `setTypeRegistry()`.
66+
67+
To access the type of mapped field, use the `ClassMetadata::getFieldType()` method.
68+
5069
## Override `Type::closureToPHP()` for custom type classes
5170

5271
The default implementation of `Doctrine\ODM\MongoDB\Types\Type::closureToPHP()`

src/Persisters/DocumentPersister.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ private function prepareQueryExpression(array $expression, ClassMetadata $class)
13831383
/**
13841384
* Checks whether the value has DBRef fields.
13851385
*
1386-
* This method doesn't check if the the value is a complete DBRef object,
1386+
* This method doesn't check if the value is a complete DBRef object,
13871387
* although it should return true for a DBRef. Rather, we're checking that
13881388
* the value has one or more fields for a DBref. In practice, this could be
13891389
* $elemMatch criteria for matching a DBRef.
@@ -1400,7 +1400,7 @@ private function hasDBRefFields($value): bool
14001400
$value = get_object_vars($value);
14011401
}
14021402

1403-
foreach ($value as $key => $value) {
1403+
foreach ($value as $key => $v) {
14041404
if ($key === '$ref' || $key === '$id' || $key === '$db') {
14051405
return true;
14061406
}

src/Types/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public static function getType(string $type): Type
134134
/**
135135
* Get a Type instance based on the type of the passed php variable.
136136
*
137-
* @deprecated Will be removed in 3.0
137+
* @deprecated Use {@see TypeRegistry::guessTypeFromValue()} instead
138138
*
139139
* @param mixed $variable
140140
*/

0 commit comments

Comments
 (0)