Skip to content

Commit

Permalink
check format
Browse files Browse the repository at this point in the history
  • Loading branch information
lsmith77 committed Nov 6, 2012
1 parent bb3a87f commit 761ebb1
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions EventListener/AccessDeniedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,19 @@ public function onKernelException(GetResponseForExceptionEvent $event)
return false;
}

// TODO do we need to do content type negotiation here?
if (empty($this->formats[$event->getRequest()->getRequestFormat()])) {
return false;
}

$handling = true;

$exception = $event->getException();
if (!$exception instanceof AccessDeniedException) {
return;
if ($exception instanceof AccessDeniedException) {
$exception = new AccessDeniedHttpException('You do not have the necessary permissions', $exception);
$event->setException($exception);
parent::onKernelException($event);
}

$exception = new AccessDeniedHttpException('You dont have the necessary permissions', $exception);
$event->setException($exception);
return parent::onKernelException($event);
}

public static function getSubscribedEvents()
Expand Down

0 comments on commit 761ebb1

Please sign in to comment.