Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #14 from maximecolin/patch-1
Browse files Browse the repository at this point in the history
Fix deprecated getException on Event
  • Loading branch information
b-viguier committed Mar 16, 2020
2 parents 4615e01 + 26c8880 commit ebb875d
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -33,17 +33,22 @@ public function __construct($dispatcher)
*/
public function onKernelException(GetResponseForExceptionEvent $event)
{
if (method_exists($event, 'getThrowable')) {
$exception = $event->getThrowable();
} else {
$exception = $event->getException();
}

// avoid subrequest
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
return;
}

if (method_exists($event->getException(), 'getStatusCode')) {
if (method_exists($exception, 'getStatusCode')) {
$this->dispatcher->dispatch('m6kernel.exception',
new KernelExceptionEvent($event->getException()->getStatusCode()));
new KernelExceptionEvent($exception->getStatusCode()));
}

$exception = $event->getException();
if ($exception instanceof RedirectException) {
$response = new RedirectResponse($exception->getUrl(), 301);
$event->setResponse($response);
Expand Down

0 comments on commit ebb875d

Please sign in to comment.