Skip to content

Commit ba9ec6b

Browse files
committed
Reworded the introduction and other minor fixes
1 parent 483f029 commit ba9ec6b

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

cookbook/event_dispatcher/event_listener.rst

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
How to Create Event Listeners and Subscribers
66
=============================================
77

8-
Symfony has various events and hooks that can be used to perform custom
9-
actions in your application. Those events are triggered by the HttpKernel
10-
component and they are defined in the :class:`Symfony\\Component\\HttpKernel\\KernelEvents`
11-
class.
8+
During the execution of a Symfony application, lots of event notifications are
9+
triggered. Your application can listen to these notifications and respond to
10+
them by executing any piece of code.
1211

13-
To hook into an event and execute your own custom logic, you have to create
14-
a service that listens to that event. As explained in this article, you can do
15-
that in two different ways: creating an event listener or an event subscriber.
12+
Internal events provided by Symfony itself are defined in the
13+
:class:`Symfony\\Component\\HttpKernel\\KernelEvents` class. Third-party bundles
14+
and libraries also trigger lots of events and your own application can trigger
15+
:doc:`custom events </components/event_dispatcher/index>`.
1616

17-
The examples of this article only use the ``KernelEvents::EXCEPTION`` event for
18-
consistency purposes. In your own application, you can use any event and even mix
19-
several of them in the same subscriber.
17+
All the examples shown in this article use the same ``KernelEvents::EXCEPTION``
18+
event for consistency purposes. In your own application, you can use any event
19+
and even mix several of them in the same subscriber.
2020

2121
Creating an Event Listener
2222
--------------------------
@@ -107,8 +107,8 @@ using a special "tag":
107107
``0`` and it controls the order in which listeners are executed (the highest
108108
the priority, the earlier a listener is executed). This is useful when you
109109
need to guarantee that one listener is executed before another. The priorities
110-
of the internal Symfony events range from ``-255`` to ``255`` but your own
111-
events can use any positive or negative integer.
110+
of the internal Symfony listeners usually range from ``-255`` to ``255`` but
111+
your own listeners can use any positive or negative integer.
112112

113113
Creating an Event Subscriber
114114
----------------------------
@@ -182,14 +182,15 @@ is an event subscriber:
182182
183183
<!-- app/config/services.xml -->
184184
<?xml version="1.0" encoding="UTF-8" ?>
185-
<container xmlns="http://symfony.com/schema/dic/services">
185+
<container xmlns="http://symfony.com/schema/dic/services"
186+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
187+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
186188
187189
<services>
188190
<service id="app.exception_subscriber"
189191
class="AppBundle\Subscriber\ExceptionSubscriber">
190192
191193
<tag name="kernel.event_subscriber"/>
192-
193194
</service>
194195
</services>
195196
</container>

0 commit comments

Comments
 (0)