From de1ff42e92b5901c8dc58f93f93422739e8b5631 Mon Sep 17 00:00:00 2001 From: Henry Snoek Date: Sat, 21 May 2016 14:42:54 +0200 Subject: [PATCH 1/2] 5953 use kernel events constants --- components/event_dispatcher/container_aware_dispatcher.rst | 3 ++- cookbook/event_dispatcher/event_listener.rst | 2 +- create_framework/http_kernel_httpkernel_class.rst | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/event_dispatcher/container_aware_dispatcher.rst b/components/event_dispatcher/container_aware_dispatcher.rst index c73d249c994..be54fa87437 100644 --- a/components/event_dispatcher/container_aware_dispatcher.rst +++ b/components/event_dispatcher/container_aware_dispatcher.rst @@ -75,7 +75,7 @@ The ``EventSubscriberInterface`` is exactly as you would expect:: public static function getSubscribedEvents() { return array( - 'kernel.response' => array( + KernelEvents::RESPONSE => array( array('onKernelResponsePre', 10), array('onKernelResponsePost', 0), ), @@ -98,3 +98,4 @@ The ``EventSubscriberInterface`` is exactly as you would expect:: // ... } } + diff --git a/cookbook/event_dispatcher/event_listener.rst b/cookbook/event_dispatcher/event_listener.rst index 4a8f263ff29..885f3235f55 100644 --- a/cookbook/event_dispatcher/event_listener.rst +++ b/cookbook/event_dispatcher/event_listener.rst @@ -149,7 +149,7 @@ listen to the same ``kernel.exception`` event:: { // return the subscribed events, their methods and priorities return array( - 'kernel.exception' => array( + KernelEvents::EXCEPTION => array( array('processException', 10), array('logException', 0), array('notifyException', -10), diff --git a/create_framework/http_kernel_httpkernel_class.rst b/create_framework/http_kernel_httpkernel_class.rst index be2a2c7a09f..abfc8dc3db7 100644 --- a/create_framework/http_kernel_httpkernel_class.rst +++ b/create_framework/http_kernel_httpkernel_class.rst @@ -166,7 +166,7 @@ only if needed:: public static function getSubscribedEvents() { - return array('kernel.view' => 'onView'); + return array(KernelEvents::VIEW => 'onView'); } } From 21b2f8184534b4255e5c7d3057d317b49c04723a Mon Sep 17 00:00:00 2001 From: Henry Snoek Date: Sat, 21 May 2016 14:55:22 +0200 Subject: [PATCH 2/2] 5953 add use statements --- components/event_dispatcher/container_aware_dispatcher.rst | 1 + cookbook/event_dispatcher/event_listener.rst | 1 + create_framework/http_kernel_httpkernel_class.rst | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/components/event_dispatcher/container_aware_dispatcher.rst b/components/event_dispatcher/container_aware_dispatcher.rst index be54fa87437..2592c19a787 100644 --- a/components/event_dispatcher/container_aware_dispatcher.rst +++ b/components/event_dispatcher/container_aware_dispatcher.rst @@ -68,6 +68,7 @@ and the second argument is the service's class name (which must implement The ``EventSubscriberInterface`` is exactly as you would expect:: use Symfony\Component\EventDispatcher\EventSubscriberInterface; + use Symfony\Component\HttpKernel\KernelEvents; // ... class StoreSubscriber implements EventSubscriberInterface diff --git a/cookbook/event_dispatcher/event_listener.rst b/cookbook/event_dispatcher/event_listener.rst index 885f3235f55..1e86e8cc8b7 100644 --- a/cookbook/event_dispatcher/event_listener.rst +++ b/cookbook/event_dispatcher/event_listener.rst @@ -142,6 +142,7 @@ listen to the same ``kernel.exception`` event:: use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; + use Symfony\Component\HttpKernel\KernelEvents; class ExceptionSubscriber implements EventSubscriberInterface { diff --git a/create_framework/http_kernel_httpkernel_class.rst b/create_framework/http_kernel_httpkernel_class.rst index abfc8dc3db7..a6c91ec2506 100644 --- a/create_framework/http_kernel_httpkernel_class.rst +++ b/create_framework/http_kernel_httpkernel_class.rst @@ -150,8 +150,9 @@ only if needed:: namespace Simplex; use Symfony\Component\EventDispatcher\EventSubscriberInterface; - use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; use Symfony\Component\HttpFoundation\Response; + use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; + use Symfony\Component\HttpKernel\KernelEvents; class StringResponseListener implements EventSubscriberInterface {