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

Skip to content

Commit 5504bd6

Browse files
committed
minor #7547 Update event_dispatcher.rst for consistency (matthieu88160)
This PR was submitted for the 3.2 branch but it was merged into the 2.7 branch instead (closes #7547). Discussion ---------- Update event_dispatcher.rst for consistency Improve event naming for example consistency with the what appends next. The event is initially named `foo.action` that break the consistency with the lines 164 and 169 of the document. Commits ------- 25c1cfc Update event_dispatcher.rst for consistency
2 parents 547227f + 25c1cfc commit 5504bd6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

components/event_dispatcher.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ A call to the dispatcher's ``addListener()`` method associates any valid
135135
PHP callable to an event::
136136

137137
$listener = new AcmeListener();
138-
$dispatcher->addListener('acme.action', array($listener, 'onFooAction'));
138+
$dispatcher->addListener('acme.foo.action', array($listener, 'onFooAction'));
139139

140140
The ``addListener()`` method takes up to three arguments:
141141

@@ -161,12 +161,12 @@ The ``addListener()`` method takes up to three arguments:
161161

162162
use Symfony\Component\EventDispatcher\Event;
163163

164-
$dispatcher->addListener('foo.action', function (Event $event) {
165-
// will be executed when the foo.action event is dispatched
164+
$dispatcher->addListener('acme.foo.action', function (Event $event) {
165+
// will be executed when the acme.foo.action event is dispatched
166166
});
167167

168168
Once a listener is registered with the dispatcher, it waits until the event
169-
is notified. In the above example, when the ``foo.action`` event is dispatched,
169+
is notified. In the above example, when the ``acme.foo.action`` event is dispatched,
170170
the dispatcher calls the ``AcmeListener::onFooAction()`` method and passes
171171
the ``Event`` object as the single argument::
172172

@@ -216,7 +216,7 @@ determine which instance is passed.
216216
// register your event listener service
217217
$listener = new Definition(\AcmeListener::class);
218218
$listener->addTag('kernel.event_listener', array(
219-
'event' => 'foo.action',
219+
'event' => 'acme.foo.action',
220220
'method' => 'onFooAction',
221221
));
222222
$containerBuilder->setDefinition('listener_service_id', $listener);

0 commit comments

Comments
 (0)