Przeglądaj źródła

renamed constants to upper cased

Fabien Potencier 14 lat temu
rodzic
commit
c171142c01

+ 11 - 11
src/Symfony/Component/HttpKernel/CoreEvents.php

@@ -19,7 +19,7 @@ namespace Symfony\Component\HttpKernel;
 final class CoreEvents
 {
     /**
-     * The onCoreRequest event occurs at the very beginning of request
+     * The REQUEST event occurs at the very beginning of request
      * dispatching
      *
      * This event allows you to create a response for a request before any
@@ -29,10 +29,10 @@ final class CoreEvents
      *
      * @var string
      */
-    const request = 'core.request';
+    const REQUEST = 'core.request';
 
     /**
-     * The onCoreException event occurs when an uncaught exception appears
+     * The EXCEPTION event occurs when an uncaught exception appears
      *
      * This event allows you to create a response for a thrown exception or
      * to modify the thrown exception. The event listener method receives
@@ -41,10 +41,10 @@ final class CoreEvents
      *
      * @var string
      */
-    const exception = 'core.exception';
+    const EXCEPTION = 'core.exception';
 
     /**
-     * The onCoreView event occurs when the return value of a controller
+     * The VIEW event occurs when the return value of a controller
      * is not a Response instance
      *
      * This event allows you to create a response for the return value of the
@@ -54,10 +54,10 @@ final class CoreEvents
      *
      * @var string
      */
-    const view = 'core.view';
+    const VIEW = 'core.view';
 
     /**
-     * The onCoreController event occurs once a controller was found for
+     * The CONTROLLER event occurs once a controller was found for
      * handling a request
      *
      * This event allows you to change the controller that will handle the
@@ -66,10 +66,10 @@ final class CoreEvents
      *
      * @var string
      */
-    const controller = 'core.controller';
+    const CONTROLLER = 'core.controller';
 
     /**
-     * The onCoreController event occurs once a response was created for
+     * The RESPONSE event occurs once a response was created for
      * replying to a request
      *
      * This event allows you to modify or replace the response that will be
@@ -78,5 +78,5 @@ final class CoreEvents
      *
      * @var string
      */
-    const response = 'core.response';
-}
+    const RESPONSE = 'core.response';
+}

+ 5 - 5
src/Symfony/Component/HttpKernel/HttpKernel.php

@@ -89,7 +89,7 @@ class HttpKernel implements HttpKernelInterface
     {
         // request
         $event = new GetResponseEvent($this, $request, $type);
-        $this->dispatcher->dispatch(CoreEvents::request, $event);
+        $this->dispatcher->dispatch(CoreEvents::REQUEST, $event);
 
         if ($event->hasResponse()) {
             return $this->filterResponse($event->getResponse(), $request, $type);
@@ -101,7 +101,7 @@ class HttpKernel implements HttpKernelInterface
         }
 
         $event = new FilterControllerEvent($this, $controller, $request, $type);
-        $this->dispatcher->dispatch(CoreEvents::controller, $event);
+        $this->dispatcher->dispatch(CoreEvents::CONTROLLER, $event);
         $controller = $event->getController();
 
         // controller arguments
@@ -113,7 +113,7 @@ class HttpKernel implements HttpKernelInterface
         // view
         if (!$response instanceof Response) {
             $event = new GetResponseForControllerResultEvent($this, $request, $type, $response);
-            $this->dispatcher->dispatch(CoreEvents::view, $event);
+            $this->dispatcher->dispatch(CoreEvents::VIEW, $event);
 
             if ($event->hasResponse()) {
                 $response = $event->getResponse();
@@ -148,7 +148,7 @@ class HttpKernel implements HttpKernelInterface
     {
         $event = new FilterResponseEvent($this, $request, $type, $response);
 
-        $this->dispatcher->dispatch(CoreEvents::response, $event);
+        $this->dispatcher->dispatch(CoreEvents::RESPONSE, $event);
 
         return $event->getResponse();
     }
@@ -165,7 +165,7 @@ class HttpKernel implements HttpKernelInterface
     private function handleException(\Exception $e, $request, $type)
     {
         $event = new GetResponseForExceptionEvent($this, $request, $type, $e);
-        $this->dispatcher->dispatch(CoreEvents::exception, $event);
+        $this->dispatcher->dispatch(CoreEvents::EXCEPTION, $event);
 
         if (!$event->hasResponse()) {
             throw $e;

+ 1 - 1
src/Symfony/Component/Security/Http/Firewall/ContextListener.php

@@ -50,7 +50,7 @@ class ContextListener implements ListenerInterface
         $this->logger = $logger;
 
         if (null !== $dispatcher) {
-            $dispatcher->addListener(CoreEvents::response, array($this, 'core.response'));
+            $dispatcher->addListener(CoreEvents::RESPONSE, array($this, 'onCoreResponse'));
         }
     }
 

+ 1 - 1
src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php

@@ -59,7 +59,7 @@ class ExceptionListener
      */
     public function register(EventDispatcherInterface $dispatcher)
     {
-        $dispatcher->addListener(CoreEvents::exception, array($this, 'core.exception'));
+        $dispatcher->addListener(CoreEvents::EXCEPTION, array($this, 'onCoreException'));
     }
 
     /**

+ 6 - 6
tests/Symfony/Tests/Component/HttpKernel/HttpCache/EsiListenerTest.php

@@ -29,9 +29,9 @@ class EsiListenerTest extends \PHPUnit_Framework_TestCase
         $response = new Response('foo <esi:include src="" />');
         $listener = new EsiListener(new Esi());
 
-        $dispatcher->addListener(CoreEvents::response, $listener);
+        $dispatcher->addListener(CoreEvents::RESPONSE, $listener);
         $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
-        $dispatcher->dispatch(CoreEvents::response, $event);
+        $dispatcher->dispatch(CoreEvents::RESPONSE, $event);
 
         $this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control'));
     }
@@ -43,9 +43,9 @@ class EsiListenerTest extends \PHPUnit_Framework_TestCase
         $response = new Response('foo <esi:include src="" />');
         $listener = new EsiListener(new Esi());
 
-        $dispatcher->addListener(CoreEvents::response, $listener);
+        $dispatcher->addListener(CoreEvents::RESPONSE, $listener);
         $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
-        $dispatcher->dispatch(CoreEvents::response, $event);
+        $dispatcher->dispatch(CoreEvents::RESPONSE, $event);
 
         $this->assertEquals('content="ESI/1.0"', $event->getResponse()->headers->get('Surrogate-Control'));
     }
@@ -57,9 +57,9 @@ class EsiListenerTest extends \PHPUnit_Framework_TestCase
         $response = new Response('foo');
         $listener = new EsiListener(new Esi());
 
-        $dispatcher->addListener(CoreEvents::response, $listener);
+        $dispatcher->addListener(CoreEvents::RESPONSE, $listener);
         $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
-        $dispatcher->dispatch(CoreEvents::response, $event);
+        $dispatcher->dispatch(CoreEvents::RESPONSE, $event);
 
         $this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control'));
     }

+ 4 - 4
tests/Symfony/Tests/Component/HttpKernel/HttpKernelTest.php

@@ -43,7 +43,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
     public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalse()
     {
         $dispatcher = new EventDispatcher();
-        $dispatcher->addListener(CoreEvents::exception, function ($event)
+        $dispatcher->addListener(CoreEvents::EXCEPTION, function ($event)
         {
             $event->setResponse(new Response($event->getException()->getMessage()));
         });
@@ -56,7 +56,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
     public function testHandleWhenAListenerReturnsAResponse()
     {
         $dispatcher = new EventDispatcher();
-        $dispatcher->addListener(CoreEvents::request, function ($event)
+        $dispatcher->addListener(CoreEvents::REQUEST, function ($event)
         {
             $event->setResponse(new Response('hello'));
         });
@@ -143,7 +143,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
     public function testHandleWhenControllerDoesNotReturnAResponseButAViewIsRegistered()
     {
         $dispatcher = new EventDispatcher();
-        $dispatcher->addListener(CoreEvents::view, function ($event)
+        $dispatcher->addListener(CoreEvents::VIEW, function ($event)
         {
             $event->setResponse(new Response($event->getControllerResult()));
         });
@@ -155,7 +155,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
     public function testHandleWithAResponseListener()
     {
         $dispatcher = new EventDispatcher();
-        $dispatcher->addListener(CoreEvents::response, function ($event)
+        $dispatcher->addListener(CoreEvents::RESPONSE, function ($event)
         {
             $event->setResponse(new Response('foo'));
         });

+ 5 - 5
tests/Symfony/Tests/Component/HttpKernel/ResponseListenerTest.php

@@ -29,7 +29,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
     {
         $this->dispatcher = new EventDispatcher();
         $listener = new ResponseListener('UTF-8');
-        $this->dispatcher->addListener(CoreEvents::response, $listener);
+        $this->dispatcher->addListener(CoreEvents::RESPONSE, $listener);
 
         $this->kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
 
@@ -39,7 +39,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
         $response = new Response('foo');
 
         $event = new FilterResponseEvent($this->kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
-        $this->dispatcher->dispatch(CoreEvents::response, $event);
+        $this->dispatcher->dispatch(CoreEvents::RESPONSE, $event);
 
         $this->assertEquals('', $event->getResponse()->headers->get('content-type'));
     }
@@ -50,7 +50,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
         $response->headers->set('Content-Type', 'text/plain');
 
         $event = new FilterResponseEvent($this->kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
-        $this->dispatcher->dispatch(CoreEvents::response, $event);
+        $this->dispatcher->dispatch(CoreEvents::RESPONSE, $event);
 
         $this->assertEquals('text/plain', $event->getResponse()->headers->get('content-type'));
     }
@@ -60,7 +60,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
         $response = new Response('foo');
 
         $event = new FilterResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response);
-        $this->dispatcher->dispatch(CoreEvents::response, $event);
+        $this->dispatcher->dispatch(CoreEvents::RESPONSE, $event);
 
         $this->assertEquals('text/html', $event->getResponse()->headers->get('content-type'));
     }
@@ -72,7 +72,7 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
         $request->setRequestFormat('json');
 
         $event = new FilterResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
-        $this->dispatcher->dispatch(CoreEvents::response, $event);
+        $this->dispatcher->dispatch(CoreEvents::RESPONSE, $event);
 
         $this->assertEquals('application/json', $event->getResponse()->headers->get('content-type'));
     }