Skip to content

Commit 8d2f75a

Browse files
committed
Add documentation regarding new features
1 parent 723561b commit 8d2f75a

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

UPGRADE-1.3.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
# UPGRADE FROM 1.2 TO 1.3
22

3+
## Events
4+
5+
### `onClassMetadataNotFound` event added
6+
7+
The default ClassMetadataFactory now triggers an `onClassMetadataNotFound` event
8+
when no metadata was found for a given class. The event args contain information
9+
about the loaded class and can store a metadata object which can be used to load
10+
custom metadata when none was found.
11+
12+
### `ResolveTargetDocumentListener` is now an event subscriber
13+
14+
The `Doctrine\ODM\MongoDB\Tools\ResolveTargetDocumentListener` class now
15+
implements the `EventSubscriber` interface. You can still register it as a
16+
listener as was necessary previously, but in order to use new functionality you
17+
have to register it as an event subscriber.
18+
19+
### `ResolveTargetDocumentListener` resolves class names on document load
20+
21+
The `Doctrine\ODM\MongoDB\Tools\ResolveTargetDocumentListener` class not only
22+
resolves class names when looking up the `targetDoccumet` of an association in
23+
a document, but it also uses the new `onClassMetadataNotFound` event to resolve
24+
class names and trigger a secondary metadata load cycle if no metadata was found
25+
for the original class name. To use this functionality, either register an event
26+
listener for the `onClassMetadataNotFound` event or register the entire class as
27+
an event subscriber.
28+
329
## GridFS
430

531
GridFS support will be rewritten for 2.0 and was deprecated in its current form.

docs/en/cookbook/resolve-target-document-listener.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Doctrine MongoDB ODM includes a utility called
1010
inside Doctrine and rewriting ``targetDocument`` parameters in your metadata
1111
mapping at runtime. This allows your bundle to use an interface or abstract
1212
class in its mappings while still allowing the mapping to resolve to a concrete
13-
document class at runtime.
13+
document class at runtime. It will also rewrite class names when no mapping
14+
metadata has been found for the original class name.
1415

1516
This functionality allows you to define relationships between different
1617
documents without creating hard dependencies.
@@ -126,7 +127,7 @@ you cannot be guaranteed that the targetDocument resolution will occur reliably:
126127
);
127128
128129
// Add the ResolveTargetDocumentListener
129-
$evm->addEventListener(\Doctrine\ODM\MongoDB\Events::loadClassMetadata, $rtdl);
130+
$evm->addEventSubscriber($rtdl);
130131
131132
// Create the document manager as you normally would
132133
$dm = \Doctrine\ODM\MongoDB\DocumentManager::create($connectionOptions, $config, $evm);

0 commit comments

Comments
 (0)