7
7
use CQRS \Domain \Model \AggregateRootInterface ;
8
8
use CQRS \EventHandling \Publisher \SimpleIdentityMap ;
9
9
use Doctrine \Common \EventSubscriber ;
10
- use Doctrine \ORM \Event \LifecycleEventArgs ;
11
10
use Doctrine \ORM \Event \OnClearEventArgs ;
11
+ use Doctrine \ORM \Event \PostLoadEventArgs ;
12
+ use Doctrine \ORM \Event \PrePersistEventArgs ;
13
+ use Doctrine \ORM \Event \PreRemoveEventArgs ;
12
14
use Doctrine \ORM \Events ;
13
15
14
16
class DoctrineIdentityMap extends SimpleIdentityMap implements EventSubscriber
@@ -23,27 +25,27 @@ public function getSubscribedEvents(): array
23
25
];
24
26
}
25
27
26
- public function postLoad (LifecycleEventArgs $ args ): void
28
+ public function postLoad (PostLoadEventArgs $ args ): void
27
29
{
28
- $ entity = $ args ->getEntity ();
30
+ $ entity = $ args ->getObject ();
29
31
30
32
if ($ entity instanceof AggregateRootInterface) {
31
33
$ this ->add ($ entity );
32
34
}
33
35
}
34
36
35
- public function prePersist (LifecycleEventArgs $ args ): void
37
+ public function prePersist (PrePersistEventArgs $ args ): void
36
38
{
37
- $ entity = $ args ->getEntity ();
39
+ $ entity = $ args ->getObject ();
38
40
39
41
if ($ entity instanceof AggregateRootInterface) {
40
42
$ this ->add ($ entity );
41
43
}
42
44
}
43
45
44
- public function preRemove (LifecycleEventArgs $ args ): void
46
+ public function preRemove (PreRemoveEventArgs $ args ): void
45
47
{
46
- $ entity = $ args ->getEntity ();
48
+ $ entity = $ args ->getObject ();
47
49
48
50
if ($ entity instanceof AggregateRootInterface) {
49
51
$ this ->remove ($ entity );
@@ -52,8 +54,6 @@ public function preRemove(LifecycleEventArgs $args): void
52
54
53
55
public function onClear (OnClearEventArgs $ args ): void
54
56
{
55
- if ($ args ->clearsAllEntities ()) {
56
- $ this ->clear ();
57
- }
57
+ $ this ->clear ();
58
58
}
59
59
}
0 commit comments