Skip to content
Snippets Groups Projects
Commit d808600d authored by catch's avatar catch
Browse files

Issue #3113876 by Hardik_Patel_12, himmatbhatia, jungle, longwave, klausi: The...

Issue #3113876 by Hardik_Patel_12, himmatbhatia, jungle, longwave, klausi: The "Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent::getException()" method is deprecated since Symfony 4.4, use "getThrowable()" instead

(cherry picked from commit a5fb386f0be8e68d4c33a8f3f11954f14ffde962)
parent 630e18e1
No related branches found
No related tags found
No related merge requests found
Showing
with 79 additions and 79 deletions
......@@ -8,7 +8,7 @@
use Drupal\Core\Session\AccountProxyInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\KernelEvents;
......@@ -105,10 +105,10 @@ public function onKernelRequestFilterProvider(GetResponseEvent $event) {
* authentication methods (e.g. basic auth) require that a challenge is sent
* to the client.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The exception event.
*/
public function onExceptionSendChallenge(GetResponseForExceptionEvent $event) {
public function onExceptionSendChallenge(ExceptionEvent $event) {
if (isset($this->challengeProvider) && $event->isMasterRequest()) {
$request = $event->getRequest();
$exception = $event->getThrowable();
......@@ -124,9 +124,9 @@ public function onExceptionSendChallenge(GetResponseForExceptionEvent $event) {
/**
* Detect disallowed authentication methods on access denied exceptions.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
*/
public function onExceptionAccessDenied(GetResponseForExceptionEvent $event) {
public function onExceptionAccessDenied(ExceptionEvent $event) {
if (isset($this->filter) && $event->isMasterRequest()) {
$request = $event->getRequest();
$exception = $event->getThrowable();
......
......@@ -10,7 +10,7 @@
use Drupal\Core\Url;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
......@@ -65,7 +65,7 @@ protected static function getPriority() {
/**
* {@inheritdoc}
*/
public function on403(GetResponseForExceptionEvent $event) {
public function on403(ExceptionEvent $event) {
$custom_403_path = $this->configFactory->get('system.site')->get('page.403');
if (!empty($custom_403_path)) {
$this->makeSubrequestToCustomPath($event, $custom_403_path, Response::HTTP_FORBIDDEN);
......@@ -75,7 +75,7 @@ public function on403(GetResponseForExceptionEvent $event) {
/**
* {@inheritdoc}
*/
public function on404(GetResponseForExceptionEvent $event) {
public function on404(ExceptionEvent $event) {
$custom_404_path = $this->configFactory->get('system.site')->get('page.404');
if (!empty($custom_404_path)) {
$this->makeSubrequestToCustomPath($event, $custom_404_path, Response::HTTP_NOT_FOUND);
......@@ -85,14 +85,14 @@ public function on404(GetResponseForExceptionEvent $event) {
/**
* Makes a subrequest to retrieve the custom error page.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
* @param string $custom_path
* The custom path to which to make a subrequest for this error message.
* @param int $status_code
* The status code for the error being handled.
*/
protected function makeSubrequestToCustomPath(GetResponseForExceptionEvent $event, $custom_path, $status_code) {
protected function makeSubrequestToCustomPath(ExceptionEvent $event, $custom_path, $status_code) {
$url = Url::fromUserInput($custom_path);
if ($url->isRouted()) {
$access_result = $this->accessManager->checkNamedRoute($url->getRouteName(), $url->getRouteParameters(), NULL, TRUE);
......
......@@ -7,7 +7,7 @@
use Drupal\Core\Utility\Error;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
......@@ -83,10 +83,10 @@ protected function getHandledFormats() {
/**
* Handles a 4xx error for HTML.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function on4xx(GetResponseForExceptionEvent $event) {
public function on4xx(ExceptionEvent $event) {
if (($exception = $event->getThrowable()) && $exception instanceof HttpExceptionInterface) {
$this->makeSubrequest($event, '/system/4xx', $exception->getStatusCode());
}
......@@ -95,44 +95,44 @@ public function on4xx(GetResponseForExceptionEvent $event) {
/**
* Handles a 401 error for HTML.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function on401(GetResponseForExceptionEvent $event) {
public function on401(ExceptionEvent $event) {
$this->makeSubrequest($event, '/system/401', Response::HTTP_UNAUTHORIZED);
}
/**
* Handles a 403 error for HTML.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function on403(GetResponseForExceptionEvent $event) {
public function on403(ExceptionEvent $event) {
$this->makeSubrequest($event, '/system/403', Response::HTTP_FORBIDDEN);
}
/**
* Handles a 404 error for HTML.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function on404(GetResponseForExceptionEvent $event) {
public function on404(ExceptionEvent $event) {
$this->makeSubrequest($event, '/system/404', Response::HTTP_NOT_FOUND);
}
/**
* Makes a subrequest to retrieve the default error page.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
* @param string $url
* The path/url to which to make a subrequest for this error message.
* @param int $status_code
* The status code for the error being handled.
*/
protected function makeSubrequest(GetResponseForExceptionEvent $event, $url, $status_code) {
protected function makeSubrequest(ExceptionEvent $event, $url, $status_code) {
$request = $event->getRequest();
$exception = $event->getThrowable();
......
......@@ -5,7 +5,7 @@
use Drupal\Core\Form\EnforcedResponse;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;
/**
......@@ -16,7 +16,7 @@ class EnforcedFormResponseSubscriber implements EventSubscriberInterface {
/**
* Replaces the response in case an EnforcedResponseException was thrown.
*/
public function onKernelException(GetResponseForExceptionEvent $event) {
public function onKernelException(ExceptionEvent $event) {
if ($response = EnforcedResponse::createFromException($event->getThrowable())) {
// Setting the response stops the event propagation.
$event->setResponse($response);
......
......@@ -6,7 +6,7 @@
use Drupal\Core\Installer\InstallerRedirectTrait;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;
/**
......@@ -35,10 +35,10 @@ public function __construct(Connection $connection) {
/**
* Handles errors for this subscriber.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function onException(GetResponseForExceptionEvent $event) {
public function onException(ExceptionEvent $event) {
$exception = $event->getThrowable();
if ($this->shouldRedirectToInstaller($exception, $this->connection)) {
// Only redirect if this is an HTML response (i.e., a user trying to view
......
......@@ -5,7 +5,7 @@
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Cache\CacheableJsonResponse;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
/**
* Default handling for JSON errors.
......@@ -31,10 +31,10 @@ protected static function getPriority() {
/**
* Handles all 4xx errors for JSON.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function on4xx(GetResponseForExceptionEvent $event) {
public function on4xx(ExceptionEvent $event) {
/** @var \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface $exception */
$exception = $event->getThrowable();
......
......@@ -5,7 +5,7 @@
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Utility\Error;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\KernelEvents;
......@@ -34,10 +34,10 @@ public function __construct(LoggerChannelFactoryInterface $logger) {
/**
* Log 403 errors.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function on403(GetResponseForExceptionEvent $event) {
public function on403(ExceptionEvent $event) {
$request = $event->getRequest();
$this->logger->get('access denied')->warning('@uri', ['@uri' => $request->getRequestUri()]);
}
......@@ -45,10 +45,10 @@ public function on403(GetResponseForExceptionEvent $event) {
/**
* Log 404 errors.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function on404(GetResponseForExceptionEvent $event) {
public function on404(ExceptionEvent $event) {
$request = $event->getRequest();
$this->logger->get('page not found')->warning('@uri', ['@uri' => $request->getRequestUri()]);
}
......@@ -56,10 +56,10 @@ public function on404(GetResponseForExceptionEvent $event) {
/**
* Log not-otherwise-specified errors, including HTTP 500.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function onError(GetResponseForExceptionEvent $event) {
public function onError(ExceptionEvent $event) {
$exception = $event->getThrowable();
$error = Error::decodeException($exception);
$this->logger->get('php')->log($error['severity_level'], '%type: @message in %function (line %line of %file).', $error);
......@@ -73,10 +73,10 @@ public function onError(GetResponseForExceptionEvent $event) {
/**
* Log all exceptions.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function onException(GetResponseForExceptionEvent $event) {
public function onException(ExceptionEvent $event) {
$exception = $event->getThrowable();
$method = 'onError';
......
......@@ -3,7 +3,7 @@
namespace Drupal\Core\EventSubscriber;
use Drupal\Core\Utility\Error;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
/**
* Custom handling of errors when in a system-under-test.
......@@ -31,9 +31,9 @@ protected function getHandledFormats() {
* original code. It's quite possible that this entire method is now
* vestigial and can be removed.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
*/
public function on500(GetResponseForExceptionEvent $event) {
public function on500(ExceptionEvent $event) {
$exception = $event->getThrowable();
$error = Error::decodeException($exception);
......
......@@ -5,7 +5,7 @@
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Component\Utility\Html;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
/**
......@@ -62,10 +62,10 @@ protected function getHandledFormats() {
/**
* Handles a 404 error for HTML.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function on404(GetResponseForExceptionEvent $event) {
public function on404(ExceptionEvent $event) {
$request = $event->getRequest();
$config = $this->configFactory->get('system.performance');
......
......@@ -8,7 +8,7 @@
use Drupal\Core\Utility\Error;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\KernelEvents;
......@@ -73,10 +73,10 @@ protected function getErrorLevel() {
/**
* Handles exceptions for this subscriber.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function onException(GetResponseForExceptionEvent $event) {
public function onException(ExceptionEvent $event) {
$exception = $event->getThrowable();
$error = Error::decodeException($exception);
......
......@@ -3,7 +3,7 @@
namespace Drupal\Core\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\KernelEvents;
......@@ -17,14 +17,14 @@
* method:
*
* @code
* public function on404(GetResponseForExceptionEvent $event) {}
* public function on404(ExceptionEvent $event) {}
* @endcode
*
* To implement a fallback for the entire 4xx class of codes, implement the
* method:
*
* @code
* public function on4xx(GetResponseForExceptionEvent $event) {}
* public function on4xx(ExceptionEvent $event) {}
* @endcode
*
* That method should then call $event->setResponse() to set the response object
......@@ -82,10 +82,10 @@ protected static function getPriority() {
/**
* Handles errors for this subscriber.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function onException(GetResponseForExceptionEvent $event) {
public function onException(ExceptionEvent $event) {
$exception = $event->getThrowable();
// Make the exception available for example when rendering a block.
......
......@@ -34,14 +34,14 @@ class EnforcedResponse extends Response {
* for an enforced response. Otherwise it would be impossible to find an
* exception thrown from within a twig template.
*
* @param \Exception $e
* @param \Throwable $e
* The exception where the enforced response is to be extracted from.
*
* @return static|null
* The enforced response or NULL if the exception chain does not contain a
* \Drupal\Core\Form\EnforcedResponseException exception.
*/
public static function createFromException(\Exception $e) {
public static function createFromException(\Throwable $e) {
while ($e) {
if ($e instanceof EnforcedResponseException) {
return new static($e->getResponse());
......
......@@ -14,7 +14,7 @@
use Drupal\Core\StringTranslation\TranslationInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;
/**
......@@ -76,10 +76,10 @@ public function onView(GetResponseForControllerResultEvent $event) {
/**
* Catches a form AJAX exception and build a response from it.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function onException(GetResponseForExceptionEvent $event) {
public function onException(ExceptionEvent $event) {
$exception = $event->getThrowable();
$request = $event->getRequest();
......
......@@ -9,7 +9,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\KernelEvents;
......@@ -72,9 +72,9 @@ protected function copyRawVariables(array $defaults) {
/**
* Catches failed parameter conversions and throw a 404 instead.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
*/
public function onException(GetResponseForExceptionEvent $event) {
public function onException(ExceptionEvent $event) {
$exception = $event->getThrowable();
if ($exception instanceof ParamNotConvertedException) {
$event->setThrowable(new NotFoundHttpException($exception->getMessage(), $exception));
......
......@@ -9,7 +9,7 @@
use Drupal\jsonapi\ResourceResponse;
use Drupal\jsonapi\Routing\Routes;
use Drupal\serialization\EventSubscriber\DefaultExceptionSubscriber as SerializationDefaultExceptionSubscriber;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
......@@ -40,7 +40,7 @@ protected function getHandledFormats() {
/**
* {@inheritdoc}
*/
public function onException(GetResponseForExceptionEvent $event) {
public function onException(ExceptionEvent $event) {
if (!$this->isJsonApiExceptionEvent($event)) {
return;
}
......@@ -55,7 +55,7 @@ public function onException(GetResponseForExceptionEvent $event) {
/**
* {@inheritdoc}
*/
protected function setEventResponse(GetResponseForExceptionEvent $event, $status) {
protected function setEventResponse(ExceptionEvent $event, $status) {
/* @var \Symfony\Component\HttpKernel\Exception\HttpException $exception */
$exception = $event->getThrowable();
$response = new ResourceResponse(new JsonApiDocumentTopLevel(new ErrorCollection([$exception]), new NullIncludedData(), new LinkCollection([])), $exception->getStatusCode(), $exception->getHeaders());
......@@ -69,13 +69,13 @@ protected function setEventResponse(GetResponseForExceptionEvent $event, $status
* The JSON:API format is supported if the format is explicitly set or the
* request is for a known JSON:API route.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $exception_event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $exception_event
* The exception event.
*
* @return bool
* TRUE if it needs to be formatted using JSON:API. FALSE otherwise.
*/
protected function isJsonApiExceptionEvent(GetResponseForExceptionEvent $exception_event) {
protected function isJsonApiExceptionEvent(ExceptionEvent $exception_event) {
$request = $exception_event->getRequest();
$parameters = $request->attributes->all();
return $request->getRequestFormat() === 'api_json' || (bool) Routes::getResourceTypeNameFromParameters($parameters);
......
......@@ -9,7 +9,7 @@
use Drupal\Core\State\StateInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\KernelEvents;
......@@ -80,10 +80,10 @@ public function __construct(KeyValueFactoryInterface $key_value, LanguageManager
/**
* Redirects not found node translations using the key value collection.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The exception event.
*/
public function onException(GetResponseForExceptionEvent $event) {
public function onException(ExceptionEvent $event) {
$exception = $event->getThrowable();
// If this is not a 404, we don't need to check for a redirection.
......
......@@ -6,7 +6,7 @@
use Drupal\Core\Cache\CacheableResponse;
use Drupal\Core\EventSubscriber\HttpExceptionSubscriberBase;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\Serializer\SerializerInterface;
/**
......@@ -64,10 +64,10 @@ protected static function getPriority() {
/**
* Handles all 4xx errors for all serialization failures.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function on4xx(GetResponseForExceptionEvent $event) {
public function on4xx(ExceptionEvent $event) {
/** @var \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface $exception */
$exception = $event->getThrowable();
$request = $event->getRequest();
......
......@@ -7,7 +7,7 @@
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Serializer\Serializer;
......@@ -27,7 +27,7 @@ public function testOn4xx() {
$request->setRequestFormat('json');
$e = new MethodNotAllowedHttpException(['POST', 'PUT'], 'test message');
$event = new GetResponseForExceptionEvent($kernel->reveal(), $request, HttpKernelInterface::MASTER_REQUEST, $e);
$event = new ExceptionEvent($kernel->reveal(), $request, HttpKernelInterface::MASTER_REQUEST, $e);
$subscriber = new DefaultExceptionSubscriber(new Serializer([], [new JsonEncoder()]), []);
$subscriber->on4xx($event);
$response = $event->getResponse();
......
......@@ -7,7 +7,7 @@
use Drupal\Core\Url;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\KernelEvents;
......@@ -41,10 +41,10 @@ public function __construct(AccountInterface $account) {
/**
* Redirects users when access is denied.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
* @param \Symfony\Component\HttpKernel\Event\ExceptionEvent $event
* The event to process.
*/
public function onException(GetResponseForExceptionEvent $event) {
public function onException(ExceptionEvent $event) {
$exception = $event->getThrowable();
if ($exception instanceof AccessDeniedHttpException) {
$route_name = RouteMatch::createFromRequest($event->getRequest())->getRouteName();
......
......@@ -12,7 +12,7 @@
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Routing\RequestContext;
......@@ -139,7 +139,7 @@ public function testHandleWithPostRequest() {
return new HtmlResponse($request->getMethod());
}));
$event = new GetResponseForExceptionEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, new NotFoundHttpException('foo'));
$event = new ExceptionEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, new NotFoundHttpException('foo'));
$this->customPageSubscriber->onException($event);
......@@ -166,7 +166,7 @@ public function testHandleWithGetRequest() {
return new Response($request->getMethod() . ' ' . UrlHelper::buildQuery($request->query->all()));
}));
$event = new GetResponseForExceptionEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, new NotFoundHttpException('foo'));
$event = new ExceptionEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, new NotFoundHttpException('foo'));
$this->customPageSubscriber->onException($event);
$response = $event->getResponse();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment