function TestMiddleware::handle

Same name in other branches
  1. 9 core/modules/system/tests/modules/httpkernel_test/src/HttpKernel/TestMiddleware.php \Drupal\httpkernel_test\HttpKernel\TestMiddleware::handle()
  2. 8.9.x core/modules/system/tests/modules/httpkernel_test/src/HttpKernel/TestMiddleware.php \Drupal\httpkernel_test\HttpKernel\TestMiddleware::handle()
  3. 11.x core/modules/system/tests/modules/http_kernel_test/src/HttpKernel/TestMiddleware.php \Drupal\http_kernel_test\HttpKernel\TestMiddleware::handle()

File

core/modules/system/tests/modules/http_kernel_test/src/HttpKernel/TestMiddleware.php, line 44

Class

TestMiddleware
Provides a test middleware.

Namespace

Drupal\http_kernel_test\HttpKernel

Code

public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE) : Response {
    $request->attributes
        ->set('_hello', 'world');
    if ($request->attributes
        ->has('_optional_argument')) {
        $request->attributes
            ->set('_previous_optional_argument', $request->attributes
            ->get('_optional_argument'));
    }
    elseif (isset($this->optionalArgument)) {
        $request->attributes
            ->set('_optional_argument', $this->optionalArgument);
    }
    return $this->kernel
        ->handle($request, $type, $catch);
}

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