class TestMiddleware in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/tests/modules/httpkernel_test/src/HttpKernel/TestMiddleware.php \Drupal\httpkernel_test\HttpKernel\TestMiddleware
Provides a test middleware.
Hierarchy
- class \Drupal\httpkernel_test\HttpKernel\TestMiddleware implements HttpKernelInterface
Expanded class hierarchy of TestMiddleware
1 string reference to 'TestMiddleware'
- httpkernel_test.services.yml in core/
modules/ system/ tests/ modules/ httpkernel_test/ httpkernel_test.services.yml - core/modules/system/tests/modules/httpkernel_test/httpkernel_test.services.yml
2 services use TestMiddleware
- httpkernel_test.test_middleware in core/
modules/ system/ tests/ modules/ httpkernel_test/ httpkernel_test.services.yml - Drupal\httpkernel_test\HttpKernel\TestMiddleware
- httpkernel_test.test_middleware2 in core/
modules/ system/ tests/ modules/ httpkernel_test/ httpkernel_test.services.yml - Drupal\httpkernel_test\HttpKernel\TestMiddleware
File
- core/
modules/ system/ tests/ modules/ httpkernel_test/ src/ HttpKernel/ TestMiddleware.php, line 16 - Contains \Drupal\httpkernel_test\HttpKernel\TestMiddleware.
Namespace
Drupal\httpkernel_test\HttpKernelView source
class TestMiddleware implements HttpKernelInterface {
/**
* The decorated kernel.
*
* @var \Symfony\Component\HttpKernel\HttpKernelInterface
*/
protected $kernel;
/**
* An optional argument.
*
* @var mixed
*/
protected $optionalArgument;
/**
* Constructs a new TestMiddleware object.
*
* @param \Symfony\Component\HttpKernel\HttpKernelInterface $kernel
* The decorated kernel.
* @param mixed $optional_argument
* (optional) An optional argument.
*/
public function __construct(HttpKernelInterface $kernel, $optional_argument = NULL) {
$this->kernel = $kernel;
$this->optionalArgument = $optional_argument;
}
/**
* {@inheritdoc}
*/
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
$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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HttpKernelInterface:: |
constant | |||
HttpKernelInterface:: |
constant | |||
TestMiddleware:: |
protected | property | The decorated kernel. | |
TestMiddleware:: |
protected | property | An optional argument. | |
TestMiddleware:: |
public | function |
Handles a Request to convert it to a Response. Overrides HttpKernelInterface:: |
|
TestMiddleware:: |
public | function | Constructs a new TestMiddleware object. |