Skip to content

Commit 6f191da

Browse files
committed
[#2301] Proofreading tweaks to Dcotrine event listeners/subcribers doc
1 parent 508e2e6 commit 6f191da

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

cookbook/doctrine/event_listeners_subscribers.rst

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,8 @@ Creating the Listener Class
121121
---------------------------
122122

123123
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::
128126

129127
// src/Acme/SearchBundle/EventListener/SearchIndexer.php
130128
namespace Acme\SearchBundle\EventListener;
@@ -153,16 +151,14 @@ itself.
153151
One important thing to notice is that a listener will be listening for *all*
154152
entities in your application. So, if you're interested in only handling a
155153
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
157155
(as shown above).
158156

159157
Creating the Subscriber Class
160158
-----------------------------
161159

162160
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::
166162

167163
// src/Acme/SearchBundle/EventListener/SearchIndexerSubscriber.php
168164
namespace Acme\SearchBundle\EventListener;
@@ -208,10 +204,10 @@ interface and an event method for each event it subscribes to.
208204

209205
Doctrine event subscribers can not return a flexible array of methods to
210206
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
212208
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.
214210

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.
216212

217213
.. _`The Event System`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html

0 commit comments

Comments
 (0)