File tree Expand file tree Collapse file tree 3 files changed +8
-4
lines changed
components/event_dispatcher
cookbook/event_dispatcher Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -68,14 +68,15 @@ and the second argument is the service's class name (which must implement
68
68
The ``EventSubscriberInterface `` is exactly as you would expect::
69
69
70
70
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
71
+ use Symfony\Component\HttpKernel\KernelEvents;
71
72
// ...
72
73
73
74
class StoreSubscriber implements EventSubscriberInterface
74
75
{
75
76
public static function getSubscribedEvents()
76
77
{
77
78
return array(
78
- 'kernel.response' => array(
79
+ KernelEvents::RESPONSE => array(
79
80
array('onKernelResponsePre', 10),
80
81
array('onKernelResponsePost', 0),
81
82
),
@@ -98,3 +99,4 @@ The ``EventSubscriberInterface`` is exactly as you would expect::
98
99
// ...
99
100
}
100
101
}
102
+
Original file line number Diff line number Diff line change @@ -142,14 +142,15 @@ listen to the same ``kernel.exception`` event::
142
142
143
143
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
144
144
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
145
+ use Symfony\Component\HttpKernel\KernelEvents;
145
146
146
147
class ExceptionSubscriber implements EventSubscriberInterface
147
148
{
148
149
public static function getSubscribedEvents()
149
150
{
150
151
// return the subscribed events, their methods and priorities
151
152
return array(
152
- 'kernel.exception' => array(
153
+ KernelEvents::EXCEPTION => array(
153
154
array('processException', 10),
154
155
array('logException', 0),
155
156
array('notifyException', -10),
Original file line number Diff line number Diff line change @@ -150,8 +150,9 @@ only if needed::
150
150
namespace Simplex;
151
151
152
152
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
153
- use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
154
153
use Symfony\Component\HttpFoundation\Response;
154
+ use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
155
+ use Symfony\Component\HttpKernel\KernelEvents;
155
156
156
157
class StringResponseListener implements EventSubscriberInterface
157
158
{
@@ -166,7 +167,7 @@ only if needed::
166
167
167
168
public static function getSubscribedEvents()
168
169
{
169
- return array('kernel.view' => 'onView');
170
+ return array(KernelEvents::VIEW => 'onView');
170
171
}
171
172
}
172
173
You can’t perform that action at this time.
0 commit comments