class FormTestMiddleware

Same name in other branches
  1. 9 core/modules/system/tests/modules/form_test/src/StackMiddleware/FormTestMiddleware.php \Drupal\form_test\StackMiddleware\FormTestMiddleware
  2. 8.9.x core/modules/system/tests/modules/form_test/src/StackMiddleware/FormTestMiddleware.php \Drupal\form_test\StackMiddleware\FormTestMiddleware
  3. 10 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

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 14

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::MAIN_REQUEST, $catch = TRUE) : Response {
        $response = $this->httpKernel
            ->handle($request, $type, $catch);
        $response->headers
            ->set('X-Form-Test-Stack-Middleware', 'invoked');
        return $response;
    }

}

Members

Title Sort descending Modifiers Object type Summary
FormTestMiddleware::$httpKernel protected property The decorated kernel.
FormTestMiddleware::handle public function
FormTestMiddleware::__construct public function Constructs a FormTestMiddleware object.

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