Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ccbf9d5

Browse files
committed
Merge branch '3.4' into 4.1
* 3.4: Improved and standardized the explanation about priorities
2 parents b9768c7 + a6fee57 commit ccbf9d5

File tree

5 files changed

+26
-20
lines changed

5 files changed

+26
-20
lines changed

components/event_dispatcher.rst

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

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

doctrine/event_listeners_subscribers.rst

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

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

252253
.. configuration-block::
253254

event_dispatcher.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ listener class:
126126
.. note::
127127

128128
There is an optional attribute for the ``kernel.event_listener`` tag called
129-
``priority``, which defaults to ``0`` and it controls the order in which
130-
listeners are executed (the higher the priority, the earlier a listener is
131-
executed). This is useful when you need to guarantee that one listener is
132-
executed before another. The priorities of the internal Symfony listeners
133-
usually range from ``-255`` to ``255`` but your own listeners can use any
134-
positive or negative integer.
129+
``priority``, which is a positive or negative integer that defaults to ``0``
130+
and it controls the order in which listeners are executed (the higher the
131+
number, the earlier a listener is executed). This is useful when you need to
132+
guarantee that one listener is executed before another. The priorities of the
133+
internal Symfony listeners usually range from ``-255`` to ``255`` but your
134+
own listeners can use any positive or negative integer.
135135

136136
.. _events-subscriber:
137137

@@ -145,7 +145,7 @@ they are listening to.
145145

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

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

profiler/data_collector.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,5 +276,7 @@ to specify a tag that contains the template:
276276
))
277277
;
278278
279-
The position of each panel in the toolbar is determined by the collector priority
280-
(the higher the priority, the earlier the panel is displayed in the toolbar).
279+
The position of each panel in the toolbar is determined by the collector priority.
280+
Priorities are defined as positive or negative integers and they default to ``0``.
281+
Most built-in collectors use ``255`` as their priority. If you want your collector
282+
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
@@ -389,8 +389,9 @@ can also register it manually:
389389
390390
.. note::
391391

392-
The ``priority`` value is optional and defaults to 0. The higher the
393-
priority, the sooner it gets executed.
392+
The ``priority`` is optional and its value is a positive or negative integer
393+
that defaults to ``0``. The higher the number, the earlier that warmers are
394+
executed.
394395

395396
.. caution::
396397

@@ -1173,8 +1174,8 @@ also register it manually:
11731174
11741175
.. note::
11751176

1176-
The ``priority`` value is optional and defaults to ``0``.
1177-
The higher priority loaders are tried first.
1177+
The ``priority`` is optional and its value is a positive or negative integer
1178+
that defaults to ``0``. Loaders with higher numbers are tried first.
11781179

11791180
.. _reference-dic-tags-twig-runtime:
11801181

0 commit comments

Comments
 (0)