Skip to content

Commit

Permalink
renamed constants to upper cased
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed May 30, 2011
1 parent f6b481a commit c171142
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
22 changes: 11 additions & 11 deletions src/Symfony/Component/HttpKernel/CoreEvents.php
Expand Up @@ -19,7 +19,7 @@
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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -78,5 +78,5 @@ final class CoreEvents
*
* @var string
*/
const response = 'core.response';
}
const RESPONSE = 'core.response';
}
10 changes: 5 additions & 5 deletions src/Symfony/Component/HttpKernel/HttpKernel.php
Expand Up @@ -89,7 +89,7 @@ private function handleRaw(Request $request, $type = self::MASTER_REQUEST)
{
// 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);
Expand All @@ -101,7 +101,7 @@ private function handleRaw(Request $request, $type = self::MASTER_REQUEST)
}

$event = new FilterControllerEvent($this, $controller, $request, $type);
$this->dispatcher->dispatch(CoreEvents::controller, $event);
$this->dispatcher->dispatch(CoreEvents::CONTROLLER, $event);
$controller = $event->getController();

// controller arguments
Expand All @@ -113,7 +113,7 @@ private function handleRaw(Request $request, $type = self::MASTER_REQUEST)
// 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();
Expand Down Expand Up @@ -148,7 +148,7 @@ private function filterResponse(Response $response, Request $request, $type)
{
$event = new FilterResponseEvent($this, $request, $type, $response);

$this->dispatcher->dispatch(CoreEvents::response, $event);
$this->dispatcher->dispatch(CoreEvents::RESPONSE, $event);

return $event->getResponse();
}
Expand All @@ -165,7 +165,7 @@ private function filterResponse(Response $response, Request $request, $type)
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;
Expand Down
Expand Up @@ -50,7 +50,7 @@ public function __construct(SecurityContext $context, array $userProviders, $con
$this->logger = $logger;

if (null !== $dispatcher) {
$dispatcher->addListener(CoreEvents::response, array($this, 'core.response'));
$dispatcher->addListener(CoreEvents::RESPONSE, array($this, 'onCoreResponse'));
}
}

Expand Down
Expand Up @@ -59,7 +59,7 @@ public function __construct(SecurityContextInterface $context, AuthenticationTru
*/
public function register(EventDispatcherInterface $dispatcher)
{
$dispatcher->addListener(CoreEvents::exception, array($this, 'core.exception'));
$dispatcher->addListener(CoreEvents::EXCEPTION, array($this, 'onCoreException'));
}

/**
Expand Down
Expand Up @@ -29,9 +29,9 @@ public function testFilterDoesNothingForSubRequests()
$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'));
}
Expand All @@ -43,9 +43,9 @@ public function testFilterWhenThereIsSomeEsiIncludes()
$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'));
}
Expand All @@ -57,9 +57,9 @@ public function testFilterWhenThereIsNoEsiIncludes()
$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'));
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Symfony/Tests/Component/HttpKernel/HttpKernelTest.php
Expand Up @@ -43,7 +43,7 @@ public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalseAndNoListe
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()));
});
Expand All @@ -56,7 +56,7 @@ public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalse()
public function testHandleWhenAListenerReturnsAResponse()
{
$dispatcher = new EventDispatcher();
$dispatcher->addListener(CoreEvents::request, function ($event)
$dispatcher->addListener(CoreEvents::REQUEST, function ($event)
{
$event->setResponse(new Response('hello'));
});
Expand Down Expand Up @@ -143,7 +143,7 @@ public function testHandleWhenControllerDoesNotReturnAResponse()
public function testHandleWhenControllerDoesNotReturnAResponseButAViewIsRegistered()
{
$dispatcher = new EventDispatcher();
$dispatcher->addListener(CoreEvents::view, function ($event)
$dispatcher->addListener(CoreEvents::VIEW, function ($event)
{
$event->setResponse(new Response($event->getControllerResult()));
});
Expand All @@ -155,7 +155,7 @@ public function testHandleWhenControllerDoesNotReturnAResponseButAViewIsRegister
public function testHandleWithAResponseListener()
{
$dispatcher = new EventDispatcher();
$dispatcher->addListener(CoreEvents::response, function ($event)
$dispatcher->addListener(CoreEvents::RESPONSE, function ($event)
{
$event->setResponse(new Response('foo'));
});
Expand Down
Expand Up @@ -29,7 +29,7 @@ protected function setUp()
{
$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');

Expand All @@ -39,7 +39,7 @@ public function testFilterDoesNothingForSubRequests()
$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'));
}
Expand All @@ -50,7 +50,7 @@ public function testFilterDoesNothingIfContentTypeIsSet()
$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'));
}
Expand All @@ -60,7 +60,7 @@ public function testFilterDoesNothingIfRequestFormatIsNotDefined()
$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'));
}
Expand All @@ -72,7 +72,7 @@ public function testFilterSetContentType()
$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'));
}
Expand Down

0 comments on commit c171142

Please sign in to comment.