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

Skip to content

Update event_dispatcher.rst for consistency #7547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions components/event_dispatcher.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ A call to the dispatcher's ``addListener()`` method associates any valid
PHP callable to an event::

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

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

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

use Symfony\Component\EventDispatcher\Event;

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

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

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