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
6868The ``EventSubscriberInterface `` is exactly as you would expect::
6969
7070 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
71+ use Symfony\Component\HttpKernel\KernelEvents;
7172 // ...
7273
7374 class StoreSubscriber implements EventSubscriberInterface
7475 {
7576 public static function getSubscribedEvents()
7677 {
7778 return array(
78- 'kernel.response' => array(
79+ KernelEvents::RESPONSE => array(
7980 array('onKernelResponsePre', 10),
8081 array('onKernelResponsePost', 0),
8182 ),
@@ -98,3 +99,4 @@ The ``EventSubscriberInterface`` is exactly as you would expect::
9899 // ...
99100 }
100101 }
102+
Original file line number Diff line number Diff line change @@ -142,14 +142,15 @@ listen to the same ``kernel.exception`` event::
142142
143143 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
144144 use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
145+ use Symfony\Component\HttpKernel\KernelEvents;
145146
146147 class ExceptionSubscriber implements EventSubscriberInterface
147148 {
148149 public static function getSubscribedEvents()
149150 {
150151 // return the subscribed events, their methods and priorities
151152 return array(
152- 'kernel.exception' => array(
153+ KernelEvents::EXCEPTION => array(
153154 array('processException', 10),
154155 array('logException', 0),
155156 array('notifyException', -10),
Original file line number Diff line number Diff line change @@ -150,8 +150,9 @@ only if needed::
150150 namespace Simplex;
151151
152152 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
153- use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
154153 use Symfony\Component\HttpFoundation\Response;
154+ use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
155+ use Symfony\Component\HttpKernel\KernelEvents;
155156
156157 class StringResponseListener implements EventSubscriberInterface
157158 {
@@ -166,7 +167,7 @@ only if needed::
166167
167168 public static function getSubscribedEvents()
168169 {
169- return array('kernel.view' => 'onView');
170+ return array(KernelEvents::VIEW => 'onView');
170171 }
171172 }
172173
You can’t perform that action at this time.
0 commit comments