Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds zone support to ExceptionListener #1406

Merged
merged 1 commit into from Mar 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions EventListener/ExceptionListener.php
Expand Up @@ -11,6 +11,8 @@

namespace FOS\RestBundle\EventListener;

use FOS\RestBundle\FOSRestBundle;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\EventListener\ExceptionListener as HttpKernelExceptionListener;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
Expand All @@ -24,6 +26,20 @@
*/
class ExceptionListener extends HttpKernelExceptionListener
{
/**
* {@inheritdoc}
*/
public function onKernelException(GetResponseForExceptionEvent $event)
{
$request = $event->getRequest();

if (!$request->attributes->get(FOSRestBundle::ZONE_ATTRIBUTE, true)) {
return;
}

parent::onKernelException($event);
}

/**
* {@inheritdoc}
*/
Expand Down