Skip to content

Commit f5efc5e

Browse files
committed
Abandon PolyglotListener as EventSubscriber
Doctrine Lifecycle Subscribers have been [abandoned in Symfony 6.4](https://symfony.com/doc/6.4/doctrine/events.html#doctrine-lifecycle-subscribers), which is why we can't use this technique anymore. Instead we revert changes from fe96e07 and declare Lifecycle Listeners.
1 parent d7c85e1 commit f5efc5e

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

src/Doctrine/PolyglotListener.php

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

1010
namespace Webfactory\Bundle\PolyglotBundle\Doctrine;
1111

12-
use Doctrine\Common\EventSubscriber;
1312
use Doctrine\ORM\EntityManager;
1413
use Doctrine\ORM\Event\PostFlushEventArgs;
1514
use Doctrine\ORM\Event\PreFlushEventArgs;
@@ -20,7 +19,7 @@
2019
use WeakReference;
2120
use Webfactory\Bundle\PolyglotBundle\Locale\DefaultLocaleProvider;
2221

23-
final class PolyglotListener implements EventSubscriber
22+
final class PolyglotListener
2423
{
2524
private const CACHE_SALT = '$WebfactoryPolyglot';
2625

@@ -56,16 +55,6 @@ public function __construct(
5655
) {
5756
}
5857

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

src/Resources/config/services.xml

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

99
<service id="Webfactory\Bundle\PolyglotBundle\Doctrine\PolyglotListener">
10-
<tag name="doctrine.event_subscriber" priority="-100" />
10+
<tag name="doctrine.event_listener" priority="-100" event="postFlush"/>
11+
<tag name="doctrine.event_listener" priority="-100" event="prePersist"/>
12+
<tag name="doctrine.event_listener" priority="-100" event="preFlush"/>
13+
<tag name="doctrine.event_listener" priority="-100" event="postLoad"/>
1114
<tag name="monolog.logger" channel="webfactory_polyglot_bundle"/>
1215
</service>
1316

0 commit comments

Comments
 (0)