File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 9
9
10
10
namespace Webfactory \Bundle \PolyglotBundle \Doctrine ;
11
11
12
+ use Doctrine \Common \EventSubscriber ;
12
13
use Doctrine \ORM \EntityManager ;
13
14
use Doctrine \ORM \Event \PostFlushEventArgs ;
14
15
use Doctrine \ORM \Event \PreFlushEventArgs ;
19
20
use WeakReference ;
20
21
use Webfactory \Bundle \PolyglotBundle \Locale \DefaultLocaleProvider ;
21
22
22
- final class PolyglotListener
23
+ final class PolyglotListener implements EventSubscriber
23
24
{
24
25
private const CACHE_SALT = '$WebfactoryPolyglot ' ;
25
26
@@ -55,6 +56,16 @@ public function __construct(
55
56
) {
56
57
}
57
58
59
+ public function getSubscribedEvents (): array
60
+ {
61
+ return [
62
+ 'prePersist ' ,
63
+ 'postLoad ' ,
64
+ 'preFlush ' ,
65
+ 'postFlush ' ,
66
+ ];
67
+ }
68
+
58
69
public function postLoad (LifecycleEventArgs $ event ): void
59
70
{
60
71
// Called when the entity has been hydrated
Original file line number Diff line number Diff line change 7
7
<defaults autowire =" true" autoconfigure =" true" />
8
8
9
9
<service id =" Webfactory\Bundle\PolyglotBundle\Doctrine\PolyglotListener" >
10
+ <tag name =" doctrine.event_subscriber" priority =" -100" />
10
11
<tag name =" doctrine.event_listener" priority =" -100" event =" postFlush" />
11
12
<tag name =" doctrine.event_listener" priority =" -100" event =" prePersist" />
12
13
<tag name =" doctrine.event_listener" priority =" -100" event =" preFlush" />
You can’t perform that action at this time.
0 commit comments