Skip to content

Commit 736d96c

Browse files
committed
[Doctrine] Invokable event listeners
1 parent 8f6a938 commit 736d96c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

doctrine/event_listeners_subscribers.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ Creating the Listener Class
9898

9999
In the previous example, a ``SearchIndexer`` service was configured as a Doctrine
100100
listener on the event ``postPersist``. The class behind that service must have
101-
a ``postPersist()`` method, which will be called when the event is dispatched::
101+
a ``postPersist()`` or an ``__invoke()`` method, which will be called when the
102+
event is dispatched::
102103

103104
// src/EventListener/SearchIndexer.php
104105
namespace App\EventListener;
@@ -123,6 +124,11 @@ a ``postPersist()`` method, which will be called when the event is dispatched::
123124
}
124125
}
125126

127+
.. versionadded:: 4.4
128+
129+
The support of the ``__invoke()`` method to create invokable event listeners
130+
was introduced in Symfony 4.4.
131+
126132
In each event, you have access to a ``LifecycleEventArgs`` object, which
127133
gives you access to both the entity object of the event and the entity manager
128134
itself.

0 commit comments

Comments
 (0)