Commit 3eb8a344 authored by catch's avatar catch
Browse files

Issue #3233031 by daffie, longwave, murilohp: [Symfony 6] Add "RequestContext"...

Issue #3233031 by daffie, longwave, murilohp: [Symfony 6] Add "RequestContext" type hint to methods overridding Symfony\Component\Routing\RequestContextAwareInterface::getContext()
parent aa1ef1a0
Loading
Loading
Loading
Loading
+1 −1
Changes for core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ public function setContext(SymfonyRequestContext $context) {
  /**
   * {@inheritdoc}
   */
  public function getContext() {
  public function getContext(): SymfonyRequestContext {
    return $this->urlGenerator->getContext();
  }

+4 −14
Changes for core/lib/Drupal/Core/Routing/AccessAwareRouter.php: 4 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -9,10 +9,8 @@
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Matcher\RequestMatcherInterface;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RequestContext as SymfonyRequestContext;
use Symfony\Component\Routing\RequestContextAwareInterface;
use Symfony\Component\Routing\RouterInterface;

/**
@@ -23,7 +21,7 @@ class AccessAwareRouter implements AccessAwareRouterInterface {
  /**
   * The router doing the actual routing.
   *
   * @var \Symfony\Component\Routing\Matcher\RequestMatcherInterface
   * @var \Symfony\Component\Routing\RouterInterface
   */
  protected $router;

@@ -44,14 +42,14 @@ class AccessAwareRouter implements AccessAwareRouterInterface {
  /**
   * Constructs a router for Drupal with access check and upcasting.
   *
   * @param \Symfony\Component\Routing\Matcher\RequestMatcherInterface $router
   * @param \Symfony\Component\Routing\RouterInterface $router
   *   The router doing the actual routing.
   * @param \Drupal\Core\Access\AccessManagerInterface $access_manager
   *   The access manager.
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The account to use in access checks.
   */
  public function __construct(RequestMatcherInterface $router, AccessManagerInterface $access_manager, AccountInterface $account) {
  public function __construct(RouterInterface $router, AccessManagerInterface $access_manager, AccountInterface $account) {
    $this->router = $router;
    $this->accessManager = $access_manager;
    $this->account = $account;
@@ -69,19 +67,15 @@ public function __call($name, $arguments) {
   * {@inheritdoc}
   */
  public function setContext(SymfonyRequestContext $context) {
    if ($this->router instanceof RequestContextAwareInterface) {
    $this->router->setContext($context);
  }
  }

  /**
   * {@inheritdoc}
   */
  public function getContext() {
    if ($this->router instanceof RequestContextAwareInterface) {
  public function getContext(): SymfonyRequestContext {
    return $this->router->getContext();
  }
  }

  /**
   * {@inheritdoc}
@@ -127,19 +121,15 @@ protected function checkAccess(Request $request) {
   * {@inheritdoc}
   */
  public function getRouteCollection(): RouteCollection {
    if ($this->router instanceof RouterInterface) {
    return $this->router->getRouteCollection();
  }
  }

  /**
   * {@inheritdoc}
   */
  public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH): string {
    if ($this->router instanceof UrlGeneratorInterface) {
    return $this->router->generate($name, $parameters, $referenceType);
  }
  }

  /**
   * {@inheritdoc}
+0 −13
Changes for core/lib/Drupal/Core/Routing/NullGenerator.php: 0 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@

use Drupal\Core\Render\BubbleableMetadata;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\RequestContext as SymfonyRequestContext;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Symfony\Component\Routing\Route;

@@ -56,18 +55,6 @@ protected function getInternalPathFromRoute($name, Route $route, $parameters = [
    return $route->getPath();
  }

  /**
   * {@inheritdoc}
   */
  public function setContext(SymfonyRequestContext $context) {
  }

  /**
   * {@inheritdoc}
   */
  public function getContext() {
  }

  /**
   * {@inheritdoc}
   */
+1 −1
Changes for core/lib/Drupal/Core/Routing/UrlGenerator.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ public function setContext(SymfonyRequestContext $context) {
  /**
   * {@inheritdoc}
   */
  public function getContext() {
  public function getContext(): SymfonyRequestContext {
    return $this->context;
  }

+1 −1
Changes for core/modules/help/tests/modules/help_test/src/SupernovaGenerator.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ public function setContext(RequestContext $context) {
  /**
   * {@inheritdoc}
   */
  public function getContext() {
  public function getContext(): RequestContext {
    throw new \Exception();
  }