Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4742859

Browse filesBrowse files
committed
fix ContainerAwareEventDispatcher definition
1 parent a578de9 commit 4742859
Copy full SHA for 4742859

File tree

Expand file treeCollapse file tree

1 file changed

+7
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-4
lines changed

‎components/event_dispatcher/introduction.rst

Copy file name to clipboardExpand all lines: components/event_dispatcher/introduction.rst
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ instance of ``Symfony\Component\HttpKernel\Event\FilterResponseEvent``::
208208
.. sidebar:: Registering Event Listeners in the Service Container
209209

210210
When you are using the
211+
:class:`Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher`
212+
and the
211213
:doc:`DependencyInjection component </components/dependency_injection/introduction>`,
212214
you can use the
213215
:class:`Symfony\\Component\\HttpKernel\\DependencyInjection\\RegisterListenersPass`
@@ -216,16 +218,17 @@ instance of ``Symfony\Component\HttpKernel\Event\FilterResponseEvent``::
216218
use Symfony\Component\DependencyInjection\ContainerBuilder;
217219
use Symfony\Component\DependencyInjection\Definition;
218220
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
221+
use Symfony\Component\DependencyInjection\Reference;
219222
use Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass;
220223

221224
$containerBuilder = new ContainerBuilder(new ParameterBag());
222225
$containerBuilder->addCompilerPass(new RegisterListenersPass());
223226

224227
// register the event dispatcher service
225-
$containerBuilder->register(
226-
'event_dispatcher',
227-
'Symfony\Component\EventDispatcher\EventDispatcher'
228-
);
228+
$containerBuilder->setDefinition('event_dispatcher', new Definition(
229+
'Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher',
230+
array(new Reference('service_container'))
231+
));
229232

230233
// register your event listener service
231234
$listener = new Definition('AcmeListener');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.