Skip to content

Commit 0fcf0c5

Browse files
committed
Keep PolyglotListener as EventSubscriberInterface
For some reason tests fail if we abandon the implementation of the `EventSubscriberInterface`
1 parent f5efc5e commit 0fcf0c5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Doctrine/PolyglotListener.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace Webfactory\Bundle\PolyglotBundle\Doctrine;
1111

12+
use Doctrine\Common\EventSubscriber;
1213
use Doctrine\ORM\EntityManager;
1314
use Doctrine\ORM\Event\PostFlushEventArgs;
1415
use Doctrine\ORM\Event\PreFlushEventArgs;
@@ -19,7 +20,7 @@
1920
use WeakReference;
2021
use Webfactory\Bundle\PolyglotBundle\Locale\DefaultLocaleProvider;
2122

22-
final class PolyglotListener
23+
final class PolyglotListener implements EventSubscriber
2324
{
2425
private const CACHE_SALT = '$WebfactoryPolyglot';
2526

@@ -55,6 +56,16 @@ public function __construct(
5556
) {
5657
}
5758

59+
public function getSubscribedEvents(): array
60+
{
61+
return [
62+
'prePersist',
63+
'postLoad',
64+
'preFlush',
65+
'postFlush',
66+
];
67+
}
68+
5869
public function postLoad(LifecycleEventArgs $event): void
5970
{
6071
// Called when the entity has been hydrated

src/Resources/config/services.xml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<defaults autowire="true" autoconfigure="true" />
88

99
<service id="Webfactory\Bundle\PolyglotBundle\Doctrine\PolyglotListener">
10+
<tag name="doctrine.event_subscriber" priority="-100" />
1011
<tag name="doctrine.event_listener" priority="-100" event="postFlush"/>
1112
<tag name="doctrine.event_listener" priority="-100" event="prePersist"/>
1213
<tag name="doctrine.event_listener" priority="-100" event="preFlush"/>

0 commit comments

Comments
 (0)