Commit c0228273 authored by catch's avatar catch
Browse files

Issue #3162981 by murilohp, andypost, quietone, paulocs, lucienchalom,...

Issue #3162981 by murilohp, andypost, quietone, paulocs, lucienchalom, longwave, daffie, catch: [Symfony 6] Use Symfony\Component\HttpFoundation\InputBag where appropriate instead of ParameterBag
parent 0722b460
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -448,7 +448,7 @@
            "dist": {
                "type": "path",
                "url": "core",
                "reference": "9b93035f22d45a6129f2709b54c86f062f11e972"
                "reference": "eefc18dedeaf145e81deed18c914b87cc2c62bd8"
            },
            "require": {
                "asm89/stack-cors": "^2.0.2",
@@ -668,7 +668,6 @@
                    "lib/Drupal/Core/DependencyInjection/Container.php",
                    "lib/Drupal/Core/DrupalKernel.php",
                    "lib/Drupal/Core/DrupalKernelInterface.php",
                    "lib/Drupal/Core/Http/InputBag.php",
                    "lib/Drupal/Core/Installer/InstallerRedirectTrait.php",
                    "lib/Drupal/Core/Site/Settings.php"
                ],
+0 −1
Original line number Diff line number Diff line
@@ -193,7 +193,6 @@
            "lib/Drupal/Core/DependencyInjection/Container.php",
            "lib/Drupal/Core/DrupalKernel.php",
            "lib/Drupal/Core/DrupalKernelInterface.php",
            "lib/Drupal/Core/Http/InputBag.php",
            "lib/Drupal/Core/Installer/InstallerRedirectTrait.php",
            "lib/Drupal/Core/Site/Settings.php"
        ],
+0 −37
Original line number Diff line number Diff line
<?php

namespace Drupal\Core\Http;

use Symfony\Component\HttpFoundation\ParameterBag;

/**
 * Forward compatibility class for Symfony 5.
 *
 * @internal only used as a bridge from Symfony 4 to Symfony 5, will be removed
 *   in drupal:10.0.0.
 */
final class InputBag extends ParameterBag {

  /**
   * Returns the parameters.
   *
   * @param string|null $key
   *   The name of the parameter to return or null to get them all.
   *
   * @return array
   *   An array of parameters.
   */
  public function all(string $key = NULL): array {
    if ($key === NULL) {
      return $this->parameters;
    }

    $value = $this->parameters[$key] ?? [];
    if (!is_array($value)) {
      throw new \UnexpectedValueException(sprintf('Unexpected value for parameter "%s": expecting "array", got "%s".', $key, get_debug_type($value)));
    }

    return $value;
  }

}
+4 −3
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
use Drupal\Core\Routing\EnhancerInterface;
use Drupal\Core\Routing\RouteObjectInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -53,7 +53,8 @@ public function enhance(array $defaults, Request $request) {
   * @param array $defaults
   *   The route defaults array.
   *
   * @return \Symfony\Component\HttpFoundation\ParameterBag
   * @return \Symfony\Component\HttpFoundation\InputBag
   *   The input bag container with the raw variables.
   */
  protected function copyRawVariables(array $defaults) {
    /** @var \Symfony\Component\Routing\Route $route */
@@ -66,7 +67,7 @@ protected function copyRawVariables(array $defaults) {
    foreach (array_intersect_key($defaults, $variables) as $key => $value) {
      $raw_variables[$key] = $value;
    }
    return new ParameterBag($raw_variables);
    return new InputBag($raw_variables);
  }

  /**
+2 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\Core\Routing;

use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\ParameterBag;

/**
@@ -48,7 +49,7 @@ public function getRawParameter($parameter_name) {
   * {@inheritdoc}
   */
  public function getRawParameters() {
    return new ParameterBag();
    return new InputBag();
  }

}
Loading