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
minor #17644 [Doctrine] Adds information on AsEntityListener attribute to the Doctrine event … (Eric)
This PR was submitted for the 6.2 branch but it was merged into the 6.0 branch instead.
Discussion
----------
[Doctrine] Adds information on AsEntityListener attribute to the Doctrine event …
Doctrine Entity Listeners can also now be defined using the AsEntityListener attribute.
This does not require the additional step of creating a service.
Documentation about this is missing from the documentation here (https://symfony.com/doc/current/doctrine/events.html#doctrine-entity-listeners).
This PR adds this to the Doctrine Entity Listeners documentation.
<!--
If your pull request fixes a BUG, use the oldest maintained branch that contains
the bug (see https://symfony.com/releases for the list of maintained branches).
If your pull request documents a NEW FEATURE, use the same Symfony branch where
the feature was introduced (and `6.x` for features of unreleased versions).
-->
Commits
-------
565e0e3 Adds information on AsEntityListener attribute to the Doctrine event documentation
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