You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doctrine/events.rst
+24Lines changed: 24 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -353,6 +353,30 @@ with the ``doctrine.orm.entity_listener`` tag:
353
353
;
354
354
};
355
355
356
+
357
+
Doctrine Entity Listeners may also be defined using PHP attributes. When using PHP attributes it is not necessary to create a service for the listener.
358
+
359
+
.. code-block:: php
360
+
361
+
// src/EventListener/UserChangedNotifier.php
362
+
namespace App\EventListener;
363
+
364
+
use App\Entity\User;
365
+
use Doctrine\Persistence\Event\LifecycleEventArgs;
366
+
use Doctrine\Bundle\DoctrineBundle\Attribute\AsEntityListener;
0 commit comments