From e97a574f9cd49e9f62f43522f62eeb9358fb72cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Sun, 27 Nov 2022 17:41:23 +0100 Subject: [PATCH] Add documentation about doctrine's AsEventListener --- .doctor-rst.yaml | 1 + doctrine/events.rst | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/.doctor-rst.yaml b/.doctor-rst.yaml index 7323d53d1dd..fac523a64da 100644 --- a/.doctor-rst.yaml +++ b/.doctor-rst.yaml @@ -80,6 +80,7 @@ whitelist: - 'The bin/console Command' - '# username is your full Gmail or Google Apps email address' - '.. _`LDAP injection`: http://projects.webappsec.org/w/page/13246947/LDAP%20Injection' + - '.. versionadded:: 2.7.2' # Doctrine - '.. versionadded:: 1.9.0' # Encore - '.. versionadded:: 0.28.4' # Encore - '.. versionadded:: 2.4.0' # SwiftMailer diff --git a/doctrine/events.rst b/doctrine/events.rst index 9a2756a4e61..1b9f2d305a4 100644 --- a/doctrine/events.rst +++ b/doctrine/events.rst @@ -149,6 +149,23 @@ with the ``doctrine.event_listener`` tag: .. configuration-block:: + .. code-block:: attribute + + // src/App/EventListener/SearchIndexer.php + namespace App\EventListener; + + use Doctrine\Bundle\DoctrineBundle\Attribute\AsEventListener; + use Doctrine\ORM\Event\LifecycleEventArgs; + + #[AsEventListener('postPersist'/*, 500, 'default'*/)] + class SearchIndexer + { + public function postPersist(LifecycleEventArgs $event): void + { + // ... + } + } + .. code-block:: yaml # config/services.yaml @@ -219,6 +236,12 @@ with the ``doctrine.event_listener`` tag: ; }; + +.. versionadded:: 2.7.2 + + The :class:`Doctrine\\Bundle\\DoctrineBundle\\Attribute\\AsEventListener` + attribute was introduced in DoctrineBundle 2.7.2. + .. tip:: Symfony loads (and instantiates) Doctrine listeners only when the related