Skip to content

Commit b6f4e09

Browse files
committed
Tweak the explanation about event priorities
1 parent 077ab13 commit b6f4e09

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

event_dispatcher.rst

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ using a special "tag":
115115
method executed by default is ``onKernelException()``.
116116

117117
The other optional tag attribute is called ``priority``, which defaults to
118-
``0`` and it controls the order in which listeners are executed (the higher
119-
the number the earlier a listener is executed). This is useful when you
120-
need to guarantee that one listener is executed before another. The priorities
121-
of the internal Symfony listeners usually range from ``-255`` to ``255`` but
122-
your own listeners can use any positive or negative integer.
118+
``0`` and it controls the order in which listeners are executed for a given
119+
event (the higher the number the earlier a listener is executed). This is
120+
useful when you need to guarantee that one listener is executed before
121+
another. The priorities of the internal Symfony listeners usually range from
122+
``-255`` to ``255`` but your own listeners can use any positive or negative integer.
123123

124124
.. _events-subscriber:
125125

@@ -131,10 +131,12 @@ that defines one or more methods that listen to one or various events. The main
131131
difference with the event listeners is that subscribers always know which events
132132
they are listening to.
133133

134-
In a given subscriber, different methods can listen to the same event. The order
135-
in which methods are executed is defined by the ``priority`` parameter of each
136-
method (the higher the number the earlier the method is called). To learn more
137-
about event subscribers, read :doc:`/components/event_dispatcher`.
134+
If different event subscriber methods listen to the same event, their order is
135+
defined by the ``priority`` parameter. This value is a positive or negative
136+
integer which defaults to ``0``. The higher the number, the earlier the method
137+
is called. **Priority is aggregated for all listeners and subscribers**, so your
138+
methods could be executed before or after the methods defined in other listeners
139+
and subscribers. To learn more about event subscribers, read :doc:`/components/event_dispatcher`.
138140

139141
The following example shows an event subscriber that defines several methods which
140142
listen to the same ``kernel.exception`` event::

0 commit comments

Comments
 (0)