function TestWaitTerminateMiddleware::handle

Same name in other branches
  1. 10 core/lib/Drupal/Core/Test/StackMiddleware/TestWaitTerminateMiddleware.php \Drupal\Core\Test\StackMiddleware\TestWaitTerminateMiddleware::handle()

File

core/lib/Drupal/Core/Test/StackMiddleware/TestWaitTerminateMiddleware.php, line 36

Class

TestWaitTerminateMiddleware
Acquire a lock to signal request termination to the test runner.

Namespace

Drupal\Core\Test\StackMiddleware

Code

public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE) : Response {
    $result = $this->httpKernel
        ->handle($request, $type, $catch);
    if ($this->state
        ->get('drupal.test_wait_terminate')) {
        // Set a header on the response to instruct the test runner that it must
        // await the lock. Note that the lock acquired here is automatically
        // released from within a shutdown function.
        $this->lock
            ->acquire('test_wait_terminate');
        $result->headers
            ->set('X-Drupal-Wait-Terminate', '1');
    }
    return $result;
}

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