Skip to content

Commit ac0da41

Browse files
committed
Merge branch '5.1'
* 5.1: Update event_dispatcher.rst
2 parents fe25210 + 03f119a commit ac0da41

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

event_dispatcher.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,17 @@ using a special "tag":
100100
.. code-block:: php
101101
102102
// config/services.php
103+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
104+
103105
use App\EventListener\ExceptionListener;
104106
105-
$container->register(ExceptionListener::class)
106-
->addTag('kernel.event_listener', ['event' => 'kernel.exception'])
107-
;
107+
return function(ContainerConfigurator $configurator) {
108+
$services = $configurator->services();
109+
110+
$services->set(ExceptionListener::class)
111+
->addTag('kernel.event_listener', ['event' => 'kernel.exception'])
112+
;
113+
};
108114
109115
Symfony follows this logic to decide which method to call inside the event
110116
listener class:

0 commit comments

Comments
 (0)