Skip to content

[Doctrine] Add documentation about Doctrine AsEventListener #17472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .doctor-rst.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions doctrine/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down