KernelPreHandle.php

Same filename and directory in other branches
  1. 11.x core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php
  2. 10 core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php
  3. 9 core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php
  4. 8.9.x core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php

Namespace

Drupal\Core\StackMiddleware

File

core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php

View source
<?php

namespace Drupal\Core\StackMiddleware;

use Drupal\Core\DrupalKernelInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;

/**
 * Prepares the environment after page caching ran.
 */
class KernelPreHandle implements HttpKernelInterface {
  public function __construct(protected HttpKernelInterface $httpKernel, protected DrupalKernelInterface $drupalKernel, protected RequestStack $requestStack) {
  }
  
  /**
   * {@inheritdoc}
   */
  public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE) : Response {
    // \Drupal\Core\DrupalKernel::preHandle() pushes requests to the stack.
    $this->drupalKernel
      ->preHandle($request);
    try {
      return $this->httpKernel
        ->handle($request, $type, $catch);
    } finally {
      // Main requests are popped in \Drupal\Core\DrupalKernel::terminate().
      if ($type !== self::MAIN_REQUEST) {
        $this->requestStack
          ->pop();
      }
    }
  }

}

Classes

Title Deprecated Summary
KernelPreHandle Prepares the environment after page caching ran.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.