Skip to content

Commit

Permalink
UserListener: use event_listener instead of subscriber (#1651)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanmac committed Jun 13, 2023
1 parent 0c92f50 commit 4049188
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Listener/UserListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

/**
* @internal
*
* NEXT_MAJOR: do not implement EventSubscriber interface anymore
*/
final class UserListener implements EventSubscriber
{
Expand All @@ -36,6 +38,9 @@ public function __construct(
) {
}

/**
* NEXT_MAJOR: remove this method.
*/
public function getSubscribedEvents(): array
{
return [
Expand Down
7 changes: 6 additions & 1 deletion src/Resources/config/mongodb.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
])

->set('sonata.user.listener.user', UserListener::class)
->tag('doctrine_mongodb.odm.event_subscriber')
->tag('doctrine_mongodb.odm.event_listener', [
'event' => 'prePersist',
])
->tag('doctrine_mongodb.odm.event_listener', [
'event' => 'preUpdate',
])
->args([
service('sonata.user.util.canonical_fields_updater'),
service('sonata.user.manager.user'),
Expand Down
7 changes: 6 additions & 1 deletion src/Resources/config/orm.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
])

->set('sonata.user.listener.user', UserListener::class)
->tag('doctrine.event_subscriber')
->tag('doctrine.event_listener', [
'event' => 'prePersist',
])
->tag('doctrine.event_listener', [
'event' => 'preUpdate',
])
->args([
service('sonata.user.util.canonical_fields_updater'),
service('sonata.user.manager.user'),
Expand Down

0 comments on commit 4049188

Please sign in to comment.