Skip to content
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

Explaining the two major ways to register an event v2 #9128

Merged
merged 3 commits into from
Oct 16, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/en/reference/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ Now you can test the ``$eventSubscriber`` instance to see if the
echo 'pre foo invoked!';
}

Registering Events
~~~~~~~~~~~~~~~~~~

There are two ways to register an event:

* *All events* can be registered by calling ``$eventManager->addEventListener()``
or ``eventManager->addEventSubscriber()`` (see :ref:`listening-and-subscribing-to-lifecycle-events`)
* *Lifecycle Callbacks* can also be registered by adding an annotation to the entity
ThomasLandauer marked this conversation as resolved.
Show resolved Hide resolved
(see :ref:`lifecycle-callbacks`)

Events Overview
---------------

Expand Down Expand Up @@ -273,6 +283,7 @@ The ``EventArgs`` instance received by the listener gives access to the entity,
:ref:`reference-events-implementing-listeners` section very carefully
to understand which operations are allowed in which lifecycle event.

.. _lifecycle-callbacks:

Lifecycle Callbacks
-------------------
Expand Down Expand Up @@ -439,6 +450,8 @@ With the additional argument you have access to the
}
}

.. _listening-and-subscribing-to-lifecycle-events:

Listening and subscribing to Lifecycle Events
---------------------------------------------

Expand Down