You are here

class FormTestMiddleware in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/form_test/src/StackMiddleware/FormTestMiddleware.php \Drupal\form_test\StackMiddleware\FormTestMiddleware

Provides a test middleware which sets a custom response header.

Hierarchy

  • class \Drupal\form_test\StackMiddleware\FormTestMiddleware implements \Symfony\Component\HttpKernel\HttpKernelInterface

Expanded class hierarchy of FormTestMiddleware

1 string reference to 'FormTestMiddleware'
form_test.services.yml in core/modules/system/tests/modules/form_test/form_test.services.yml
core/modules/system/tests/modules/form_test/form_test.services.yml
1 service uses FormTestMiddleware
form_test.http_middleware in core/modules/system/tests/modules/form_test/form_test.services.yml
Drupal\form_test\StackMiddleware\FormTestMiddleware

File

core/modules/system/tests/modules/form_test/src/StackMiddleware/FormTestMiddleware.php, line 11

Namespace

Drupal\form_test\StackMiddleware
View source
class FormTestMiddleware implements HttpKernelInterface {

  /**
   * The decorated kernel.
   *
   * @var \Symfony\Component\HttpKernel\HttpKernelInterface
   */
  protected $httpKernel;

  /**
   * Constructs a FormTestMiddleware object.
   *
   * @param \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel
   *   The decorated kernel.
   */
  public function __construct(HttpKernelInterface $http_kernel) {
    $this->httpKernel = $http_kernel;
  }

  /**
   * {@inheritdoc}
   */
  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
    $response = $this->httpKernel
      ->handle($request, $type, $catch);
    $response->headers
      ->set('X-Form-Test-Stack-Middleware', 'invoked');
    return $response;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FormTestMiddleware::$httpKernel protected property The decorated kernel.
FormTestMiddleware::handle public function
FormTestMiddleware::__construct public function Constructs a FormTestMiddleware object.