Commit 11613ac1 authored by Albert Skibinski's avatar Albert Skibinski Committed by Sascha Grossenbacher
Browse files

Issue #3130096 by askibinski, KapilV, saphemmy: Deprecated Symfony Event classes

parent a250cc06
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -8,10 +8,10 @@ use Drupal\Core\Path\PathMatcherInterface;
use Drupal\redirect_404\RedirectNotFoundStorageInterface;
use Drupal\Core\Path\CurrentPathStack;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;

/**
 * An EventSubscriber that listens to redirect 404 errors.
@@ -96,12 +96,12 @@ class Redirect404Subscriber implements EventSubscriberInterface {
  /**
   * Logs an exception of 404 Redirect errors.
   *
   * @param GetResponseForExceptionEvent $event
   * @param ExceptionEvent $event
   *   Is given by the event dispatcher.
   */
  public function onKernelException(GetResponseForExceptionEvent $event) {
  public function onKernelException(ExceptionEvent $event) {
    // Only log page not found (404) errors.
    if ($event->getException() instanceof NotFoundHttpException) {
    if ($event->getThrowable() instanceof NotFoundHttpException) {
      $path = $this->currentPath->getPath();

      // Ignore paths specified in the redirect settings.
+5 −5
Original line number Diff line number Diff line
@@ -7,8 +7,8 @@ use Drupal\Core\Path\PathMatcherInterface;
use Drupal\Core\Routing\TrustedRedirectResponse;
use Drupal\Core\Url;
use Drupal\redirect\RedirectChecker;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
@@ -62,10 +62,10 @@ class DomainRedirectRequestSubscriber implements EventSubscriberInterface {
  /**
   * Handles the domain redirect if any found.
   *
   * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   * @param \Symfony\Component\HttpKernel\Event\RequestEvent $event
   *   The event to process.
   */
  public function onKernelRequestCheckDomainRedirect(GetResponseEvent $event) {
  public function onKernelRequestCheckDomainRedirect(RequestEvent $event) {
    $request = clone $event->getRequest();

    if (!$this->redirectChecker->canRedirect($request)) {
@@ -111,12 +111,12 @@ class DomainRedirectRequestSubscriber implements EventSubscriberInterface {
  /**
   * Prior to set the response it check if we can redirect.
   *
   * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   * @param \Symfony\Component\HttpKernel\Event\RequestEvent $event
   *   The event object.
   * @param \Drupal\Core\Url $url
   *   The Url where we want to redirect.
   */
  protected function setResponse(GetResponseEvent $event, Url $url) {
  protected function setResponse(RequestEvent $event, Url $url) {
    $request = $event->getRequest();

    parse_str($request->getQueryString(), $query);
+3 −3
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ use Drupal\redirect_domain\EventSubscriber\DomainRedirectRequestSubscriber;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;

/**
@@ -128,7 +128,7 @@ class DomainRedirectRequestSubscriberTest extends UnitTestCase {
   * @param $query_string
   *   The query string in the url.
   *
   * @return GetResponseEvent
   * @return RequestEvent
   *   The response for the request.
   */
  protected function getGetResponseEventStub($path_info, $query_string) {
@@ -136,7 +136,7 @@ class DomainRedirectRequestSubscriberTest extends UnitTestCase {

    $http_kernel = $this->getMockBuilder(HttpKernelInterface::class)
      ->getMock();
    return new GetResponseEvent($http_kernel, $request, HttpKernelInterface::MASTER_REQUEST);
    return new RequestEvent($http_kernel, $request, HttpKernelInterface::MASTER_REQUEST);
  }

  /**
+5 −5
Original line number Diff line number Diff line
@@ -15,8 +15,8 @@ use Drupal\redirect\Exception\RedirectLoopException;
use Drupal\redirect\RedirectChecker;
use Drupal\redirect\RedirectRepository;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Routing\RequestContext;

@@ -105,10 +105,10 @@ class RedirectRequestSubscriber implements EventSubscriberInterface {
  /**
   * Handles the redirect if any found.
   *
   * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   * @param \Symfony\Component\HttpKernel\Event\RequestEvent $event
   *   The event to process.
   */
  public function onKernelRequestCheckRedirect(GetResponseEvent $event) {
  public function onKernelRequestCheckRedirect(RequestEvent $event) {
    // Get a clone of the request. During inbound processing the request
    // can be altered. Allowing this here can lead to unexpected behavior.
    // For example the path_processor.files inbound processor provided by
@@ -176,12 +176,12 @@ class RedirectRequestSubscriber implements EventSubscriberInterface {
  /**
   * Prior to set the response it check if we can redirect.
   *
   * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   * @param \Symfony\Component\HttpKernel\Event\RequestEvent $event
   *   The event object.
   * @param \Drupal\Core\Url $url
   *   The Url where we want to redirect.
   */
  protected function setResponse(GetResponseEvent $event, Url $url) {
  protected function setResponse(RequestEvent $event, Url $url) {
    $request = $event->getRequest();
    $this->context->fromRequest($request);

+3 −2
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ use Drupal\Core\Routing\RequestHelper;
use Drupal\Core\Routing\TrustedRedirectResponse;
use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\redirect\RedirectChecker;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@@ -80,10 +81,10 @@ class RouteNormalizerRequestSubscriber implements EventSubscriberInterface {
   *   page.
   * - Requested path has an alias: redirect to alias.
   *
   * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
   * @param \Symfony\Component\HttpKernel\Event\RequestEvent $event
   *   The Event to process.
   */
  public function onKernelRequestRedirect(GetResponseEvent $event) {
  public function onKernelRequestRedirect(RequestEvent $event) {

    if (!$this->config->get('route_normalizer_enabled') || !$event->isMasterRequest()) {
      return;
Loading