Issue #3113876 by Hardik_Patel_12, himmatbhatia, jungle, klausi, longwave: The "Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent::getException()" method is deprecated since Symfony 4.4, use "getThrowable()" instead
parent
f14155d513
commit
5c457b5509
|
@ -8,7 +8,7 @@ use Drupal\Core\Authentication\AuthenticationProviderInterface;
|
|||
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 @@ class AuthenticationSubscriber implements EventSubscriberInterface {
|
|||
* 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 @@ class AuthenticationSubscriber implements EventSubscriberInterface {
|
|||
/**
|
||||
* 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\Routing\RedirectDestinationInterface;
|
|||
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 @@ class CustomPageExceptionHtmlSubscriber extends DefaultExceptionHtmlSubscriber {
|
|||
/**
|
||||
* {@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 @@ class CustomPageExceptionHtmlSubscriber extends DefaultExceptionHtmlSubscriber {
|
|||
/**
|
||||
* {@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 @@ class CustomPageExceptionHtmlSubscriber extends DefaultExceptionHtmlSubscriber {
|
|||
/**
|
||||
* 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\Routing\RedirectDestinationInterface;
|
|||
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 @@ class DefaultExceptionHtmlSubscriber extends HttpExceptionSubscriberBase {
|
|||
/**
|
||||
* 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 @@ class DefaultExceptionHtmlSubscriber extends HttpExceptionSubscriberBase {
|
|||
/**
|
||||
* 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 @@ namespace Drupal\Core\EventSubscriber;
|
|||
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\Database\Connection;
|
|||
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 @@ class ExceptionDetectNeedsInstallSubscriber implements EventSubscriberInterface
|
|||
/**
|
||||
* 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 @@ namespace Drupal\Core\EventSubscriber;
|
|||
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 @@ class ExceptionJsonSubscriber extends HttpExceptionSubscriberBase {
|
|||
/**
|
||||
* 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 @@ namespace Drupal\Core\EventSubscriber;
|
|||
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 @@ class ExceptionLoggingSubscriber implements EventSubscriberInterface {
|
|||
/**
|
||||
* 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 @@ class ExceptionLoggingSubscriber implements EventSubscriberInterface {
|
|||
/**
|
||||
* 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 @@ class ExceptionLoggingSubscriber implements EventSubscriberInterface {
|
|||
/**
|
||||
* 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 @@ class ExceptionLoggingSubscriber implements EventSubscriberInterface {
|
|||
/**
|
||||
* 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 @@ class ExceptionTestSiteSubscriber extends HttpExceptionSubscriberBase {
|
|||
* 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 @@ namespace Drupal\Core\EventSubscriber;
|
|||
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 @@ class Fast404ExceptionHtmlSubscriber extends HttpExceptionSubscriberBase {
|
|||
/**
|
||||
* 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\StringTranslation\StringTranslationTrait;
|
|||
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 @@ class FinalExceptionSubscriber implements EventSubscriberInterface {
|
|||
/**
|
||||
* 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 @@ use Symfony\Component\HttpKernel\KernelEvents;
|
|||
* 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 @@ abstract class HttpExceptionSubscriberBase implements EventSubscriberInterface {
|
|||
/**
|
||||
* 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\StringTranslationTrait;
|
|||
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 @@ class FormAjaxSubscriber implements EventSubscriberInterface {
|
|||
/**
|
||||
* 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\Cmf\Component\Routing\RouteObjectInterface;
|
|||
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 @@ class ParamConversionEnhancer implements EnhancerInterface, EventSubscriberInter
|
|||
/**
|
||||
* 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\JsonApiResource\NullIncludedData;
|
|||
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 @@ class DefaultExceptionSubscriber extends SerializationDefaultExceptionSubscriber
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function onException(GetResponseForExceptionEvent $event) {
|
||||
public function onException(ExceptionEvent $event) {
|
||||
if (!$this->isJsonApiExceptionEvent($event)) {
|
||||
return;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class DefaultExceptionSubscriber extends SerializationDefaultExceptionSubscriber
|
|||
/**
|
||||
* {@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 @@ class DefaultExceptionSubscriber extends SerializationDefaultExceptionSubscriber
|
|||
* 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\Routing\UrlGeneratorInterface;
|
|||
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 @@ class NodeTranslationExceptionSubscriber implements EventSubscriberInterface {
|
|||
/**
|
||||
* 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\CacheableDependencyInterface;
|
|||
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 @@ class DefaultExceptionSubscriber extends HttpExceptionSubscriberBase {
|
|||
/**
|
||||
* 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\serialization\EventSubscriber\DefaultExceptionSubscriber;
|
|||
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 @@ class DefaultExceptionSubscriberTest extends UnitTestCase {
|
|||
$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\Routing\RouteMatch;
|
|||
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 @@ class AccessDeniedSubscriber implements EventSubscriberInterface {
|
|||
/**
|
||||
* 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\Core\Url;
|
|||
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 @@ class CustomPageExceptionHtmlSubscriberTest extends UnitTestCase {
|
|||
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 @@ class CustomPageExceptionHtmlSubscriberTest extends UnitTestCase {
|
|||
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();
|
||||
|
|
|
@ -9,7 +9,7 @@ use Drupal\Core\Http\Exception\CacheableMethodNotAllowedHttpException;
|
|||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
@ -27,7 +27,7 @@ class ExceptionJsonSubscriberTest extends UnitTestCase {
|
|||
public function testOn4xx(HttpExceptionInterface $exception, $expected_response_class) {
|
||||
$kernel = $this->prophesize(HttpKernelInterface::class);
|
||||
$request = Request::create('/test');
|
||||
$event = new GetResponseForExceptionEvent($kernel->reveal(), $request, HttpKernelInterface::MASTER_REQUEST, $exception);
|
||||
$event = new ExceptionEvent($kernel->reveal(), $request, HttpKernelInterface::MASTER_REQUEST, $exception);
|
||||
$subscriber = new ExceptionJsonSubscriber();
|
||||
$subscriber->on4xx($event);
|
||||
$response = $event->getResponse();
|
||||
|
|
|
@ -6,7 +6,7 @@ use Drupal\Core\EventSubscriber\FinalExceptionSubscriber;
|
|||
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;
|
||||
|
||||
|
@ -28,7 +28,7 @@ class FinalExceptionSubscriberTest extends UnitTestCase {
|
|||
// of this so we'll hard code it here.
|
||||
$request->setRequestFormat('bananas');
|
||||
$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 TestDefaultExceptionSubscriber($config_factory);
|
||||
$subscriber->setStringTranslation($this->getStringTranslationStub());
|
||||
$subscriber->onException($event);
|
||||
|
|
|
@ -12,7 +12,7 @@ use Drupal\Core\Messenger\MessengerInterface;
|
|||
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\HttpException;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
|
@ -191,7 +191,7 @@ class FormAjaxSubscriberTest extends UnitTestCase {
|
|||
$exception = new BrokenPostRequestException(32 * 1e6);
|
||||
$request = new Request([FormBuilderInterface::AJAX_FORM_REQUEST => TRUE]);
|
||||
|
||||
$event = new GetResponseForExceptionEvent($this->httpKernel, $request, HttpKernelInterface::MASTER_REQUEST, $exception);
|
||||
$event = new ExceptionEvent($this->httpKernel, $request, HttpKernelInterface::MASTER_REQUEST, $exception);
|
||||
$this->subscriber->onException($event);
|
||||
$this->assertTrue($event->isAllowingCustomResponseCode());
|
||||
$actual_response = $event->getResponse();
|
||||
|
@ -256,11 +256,11 @@ class FormAjaxSubscriberTest extends UnitTestCase {
|
|||
* @param \Symfony\Component\HttpFoundation\Response|null $expected_response
|
||||
* The response expected to be set on the event.
|
||||
*
|
||||
* @return \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent
|
||||
* @return \Symfony\Component\HttpKernel\Event\ExceptionEvent
|
||||
* The event used to derive the response.
|
||||
*/
|
||||
protected function assertResponseFromException(Request $request, \Exception $exception, $expected_response) {
|
||||
$event = new GetResponseForExceptionEvent($this->httpKernel, $request, HttpKernelInterface::MASTER_REQUEST, $exception);
|
||||
$event = new ExceptionEvent($this->httpKernel, $request, HttpKernelInterface::MASTER_REQUEST, $exception);
|
||||
$this->subscriber->onException($event);
|
||||
|
||||
$this->assertSame($expected_response, $event->getResponse());
|
||||
|
|
Loading…
Reference in New Issue