Skip to content

Commit 779e491

Browse files
committed
minor symfony#10663 Improved and standardized the explanation about priorities (javiereguiluz)
This PR was squashed before being merged into the 2.8 branch (closes symfony#10663). Discussion ---------- Improved and standardized the explanation about priorities This is a continuation of symfony#10655. Commits ------- 192b6a8 Improved and standardized the explanation about priorities
2 parents 905d799 + 192b6a8 commit 779e491

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

components/event_dispatcher.rst

+7-5
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

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

doctrine/event_listeners_subscribers.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,9 @@ Priorities for Event Listeners
276276
------------------------------
277277

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

282283
.. configuration-block::
283284

event_dispatcher.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ using a special "tag":
119119

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

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

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

profiler/data_collector.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,9 @@ the ``data_collector`` tag in your service configuration:
315315
The ``id`` attribute must match the value returned by the ``getName()`` method.
316316

317317
The position of each panel in the toolbar is determined by the priority defined
318-
by each collector. Most built-in collectors use ``255`` as their priority. If you
319-
want your collector to be displayed before them, use a higher value:
318+
by each collector. Priorities are defined as positive or negative integers and
319+
they default to ``0``. Most built-in collectors use ``255`` as their priority.
320+
If you want your collector to be displayed before them, use a higher value:
320321

321322
.. configuration-block::
322323

reference/dic_tags.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,9 @@ tag:
568568
569569
.. note::
570570

571-
The ``priority`` value is optional and defaults to 0. The higher the
572-
priority, the sooner it gets executed.
571+
The ``priority`` is optional and its value is a positive or negative integer
572+
that defaults to ``0``. The higher the number, the earlier that warmers are
573+
executed.
573574

574575
.. caution::
575576

@@ -1422,8 +1423,8 @@ the new loader and tag it with ``twig.loader``:
14221423
14231424
.. note::
14241425

1425-
The ``priority`` value is optional and defaults to ``0``.
1426-
The higher priority loaders are tried first.
1426+
The ``priority`` is optional and its value is a positive or negative integer
1427+
that defaults to ``0``. Loaders with higher numbers are tried first.
14271428

14281429
validator.constraint_validator
14291430
------------------------------

0 commit comments

Comments
 (0)