Skip to content

Commit a6fee57

Browse files
committed
Merge branch '2.8' into 3.4
* 2.8: Improved and standardized the explanation about priorities
2 parents d07a5b9 + 779e491 commit a6fee57

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

components/event_dispatcher.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ The ``addListener()`` method takes up to three arguments:
148148
#. The event name (string) that this listener wants to listen to;
149149
#. A PHP callable that will be executed when the specified event is dispatched;
150150
#. An optional priority, defined as a positive or negative integer (defaults to
151-
``0``). The higher the priority, the earlier the listener is called. If two
151+
``0``). The higher the number, the earlier the listener is called. If two
152152
listeners have the same priority, they are executed in the order that they
153153
were added to the dispatcher.
154154

@@ -384,10 +384,12 @@ method::
384384
The dispatcher will automatically register the subscriber for each event
385385
returned by the ``getSubscribedEvents()`` method. This method returns an array
386386
indexed by event names and whose values are either the method name to call
387-
or an array composed of the method name to call and a priority. The example
388-
above shows how to register several listener methods for the same event
389-
in subscriber and also shows how to pass the priority of each listener method.
390-
The higher the priority, the earlier the method is called. In the above
387+
or an array composed of the method name to call and a priority (a positive or
388+
negative integer that defaults to ``0``).
389+
390+
The example above shows how to register several listener methods for the same
391+
event in subscriber and also shows how to pass the priority of each listener
392+
method. The higher the number, the earlier the method is called. In the above
391393
example, when the ``kernel.response`` event is triggered, the methods
392394
``onKernelResponsePre()`` and ``onKernelResponsePost()`` are called in that
393395
order.

doctrine/event_listeners_subscribers.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@ Priorities for Event Listeners
247247
------------------------------
248248

249249
In case you have multiple listeners for the same event you can control the order
250-
in which they are invoked using the ``priority`` attribute on the tag.
251-
Listeners with a higher priority are invoked first.
250+
in which they are invoked using the ``priority`` attribute on the tag. Priorities
251+
are defined with positive or negative integers (they default to ``0``). Higher
252+
numbers mean that listeners are invoked earlier.
252253

253254
.. configuration-block::
254255

event_dispatcher.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ using a special "tag":
116116

117117
The other optional tag attribute is called ``priority``, which defaults to
118118
``0`` and it controls the order in which listeners are executed (the higher
119-
the priority the earlier a listener is executed). This is useful when you
119+
the number the earlier a listener is executed). This is useful when you
120120
need to guarantee that one listener is executed before another. The priorities
121121
of the internal Symfony listeners usually range from ``-255`` to ``255`` but
122122
your own listeners can use any positive or negative integer.
@@ -133,7 +133,7 @@ they are listening to.
133133

134134
In a given subscriber, different methods can listen to the same event. The order
135135
in which methods are executed is defined by the ``priority`` parameter of each
136-
method (the higher the priority the earlier the method is called). To learn more
136+
method (the higher the number the earlier the method is called). To learn more
137137
about event subscribers, read :doc:`/components/event_dispatcher`.
138138

139139
The following example shows an event subscriber that defines several methods which

profiler/data_collector.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,5 +286,6 @@ to specify a tag that contains the template:
286286
;
287287
288288
The position of each panel in the toolbar is determined by the priority defined
289-
by each collector. Most built-in collectors use ``255`` as their priority. If you
290-
want your collector to be displayed before them, use a higher value (like 300).
289+
by each collector. Priorities are defined as positive or negative integers and
290+
they default to ``0``. Most built-in collectors use ``255`` as their priority.
291+
If you want your collector to be displayed before them, use a higher value (like 300).

reference/dic_tags.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,9 @@ can also register it manually:
571571
572572
.. note::
573573

574-
The ``priority`` value is optional and defaults to 0. The higher the
575-
priority, the sooner it gets executed.
574+
The ``priority`` is optional and its value is a positive or negative integer
575+
that defaults to ``0``. The higher the number, the earlier that warmers are
576+
executed.
576577

577578
.. caution::
578579

@@ -1337,8 +1338,8 @@ also register it manually:
13371338
13381339
.. note::
13391340

1340-
The ``priority`` value is optional and defaults to ``0``.
1341-
The higher priority loaders are tried first.
1341+
The ``priority`` is optional and its value is a positive or negative integer
1342+
that defaults to ``0``. Loaders with higher numbers are tried first.
13421343

13431344
validator.constraint_validator
13441345
------------------------------

0 commit comments

Comments
 (0)