@@ -121,10 +121,8 @@ Creating the Listener Class
121
121
---------------------------
122
122
123
123
In the previous example, a service ``my.listener `` was configured as a Doctrine
124
- listener on the event ``postPersist ``. That class behind that service must have
125
- a ``postPersist `` method, which will be called when the event is thrown.
126
-
127
- .. code-block::php
124
+ listener on the event ``postPersist ``. The class behind that service must have
125
+ a ``postPersist `` method, which will be called when the event is dispatched::
128
126
129
127
// src/Acme/SearchBundle/EventListener/SearchIndexer.php
130
128
namespace Acme\SearchBundle\EventListener;
@@ -153,16 +151,14 @@ itself.
153
151
One important thing to notice is that a listener will be listening for *all *
154
152
entities in your application. So, if you're interested in only handling a
155
153
specific type of entity (e.g. a ``Product `` entity but not a ``BlogPost ``
156
- entity), you should check for the class name of the entity in your method
154
+ entity), you should check for the entity's class type in your method
157
155
(as shown above).
158
156
159
157
Creating the Subscriber Class
160
158
-----------------------------
161
159
162
160
A doctrine event subscriber must implement the ``Doctrine\Common\EventSubscriber ``
163
- interface and an event method for each event it subscribes to.
164
-
165
- .. code-block::php
161
+ interface and have an event method for each event it subscribes to::
166
162
167
163
// src/Acme/SearchBundle/EventListener/SearchIndexerSubscriber.php
168
164
namespace Acme\SearchBundle\EventListener;
@@ -208,10 +204,10 @@ interface and an event method for each event it subscribes to.
208
204
209
205
Doctrine event subscribers can not return a flexible array of methods to
210
206
call for the events like the :ref: `Symfony event subscriber <event_dispatcher-using-event-subscribers >`
211
- can do . Doctrine event subscribers must return a simple array of the event
207
+ can. Doctrine event subscribers must return a simple array of the event
212
208
names they subscribe to. Doctrine will then expect methods on the subscriber
213
- with the names of the subscribed events , just as when using an event listener.
209
+ with the same name as each subscribed event , just as when using an event listener.
214
210
215
- For a full reference, see chapter `The Event System ` in the doctrine documentation.
211
+ For a full reference, see chapter `The Event System `_ in the Doctrine documentation.
216
212
217
213
.. _`The Event System` : http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html
0 commit comments