Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TestWaitTerminateMiddleware.php

class TestWaitTerminateMiddleware

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

Hierarchy

  • class \Drupal\Core\Test\StackMiddleware\TestWaitTerminateMiddleware implements \Symfony\Component\HttpKernel\HttpKernelInterface

Expanded class hierarchy of TestWaitTerminateMiddleware

File

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

Namespace

Drupal\Core\Test\StackMiddleware
View source
class TestWaitTerminateMiddleware implements HttpKernelInterface {
    
    /**
     * Constructs a test wait terminate stack middleware object.
     *
     * @param \Symfony\Component\HttpKernel\HttpKernelInterface $httpKernel
     *   The decorated kernel.
     * @param \Drupal\Core\State\StateInterface $state
     *   The state server.
     * @param \Drupal\Core\Lock\LockBackendInterface $lock
     *   The lock backend.
     */
    public function __construct(HttpKernelInterface $httpKernel, StateInterface $state, LockBackendInterface $lock) {
    }
    
    /**
     * {@inheritdoc}
     */
    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;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
HttpKernelInterface::MAIN_REQUEST public constant
HttpKernelInterface::SUB_REQUEST public constant
TestWaitTerminateMiddleware::handle public function Handles a Request to convert it to a Response. Overrides HttpKernelInterface::handle
TestWaitTerminateMiddleware::__construct public function Constructs a test wait terminate stack middleware object.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal