You are here

class RequestStack in Drupal 9

Forward-compatibility shim for Symfony's RequestStack.

@todo Remove when Symfony 5.3 or greater is required.

Hierarchy

  • class \Drupal\Core\Http\RequestStack extends \Symfony\Component\HttpFoundation\RequestStack

Expanded class hierarchy of RequestStack

2 files declare their use of RequestStack
RendererTestBase.php in core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
Contains \Drupal\Tests\Core\Render\RendererTestBase.
RequestStackLegacyTest.php in core/tests/Drupal/Tests/Core/Http/RequestStackLegacyTest.php
1 string reference to 'RequestStack'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses RequestStack
request_stack in core/core.services.yml
Drupal\Core\Http\RequestStack

File

core/lib/Drupal/Core/Http/RequestStack.php, line 13

Namespace

Drupal\Core\Http
View source
class RequestStack extends SymfonyRequestStack {

  /**
   * Gets the main request.
   *
   * @return \Symfony\Component\HttpFoundation\Request|null
   *   The main request.
   */
  public function getMainRequest() : ?Request {
    if (method_exists(SymfonyRequestStack::class, 'getMainRequest')) {
      return parent::getMainRequest();
    }
    else {
      return parent::getMasterRequest();
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getMasterRequest() {
    @trigger_error('Drupal\\Core\\Http\\RequestStack::getMasterRequest() is deprecated, use getMainRequest() instead.', E_USER_DEPRECATED);
    return $this
      ->getMainRequest();
  }

}

Members