/Drupal 8

class StackedKernelPass

Provides a compiler pass for stacked HTTP kernels.

Builds the HTTP kernel by collecting all services tagged 'http_middleware' and assembling them into a StackedKernel. The middleware with the lowest priority ends up as the outermost while the highest priority middleware wraps the actual HTTP kernel defined by the http_kernel.basic service.

The 'http_middleware' service tag additionally accepts a 'responder' parameter. It should be set to TRUE if many or most requests will be handled directly by the middleware. Any underlying middleware and the HTTP kernel are then flagged as 'lazy'. As a result those low priority services and their dependencies are only initialized if the 'responder' middleware fails to generate a response and the request is delegated to the underlying kernel.

In general middlewares should not have heavy dependencies. This is especially important for high-priority services which need to run before the internal page cache.

An example of a high priority middleware.

  class: Drupal\Core\StackMiddleware\ReverseProxyMiddleware
  arguments: ['@settings']
    - { name: http_middleware, priority: 300 }

An example of a responder middleware:

  class: Drupal\page_cache\StackMiddleware\PageCache
  arguments: ['@cache.render', '@page_cache_request_policy', '@page_cache_response_policy']
    - { name: http_middleware, priority: 200, responder: true }


See also



core/lib/Drupal/Core/DependencyInjection/Compiler/StackedKernelPass.php, line 48




Name Modifiers Type Description
StackedKernelPass::process public function You can modify the container here before it is dumped to PHP code. Overrides CompilerPassInterface::process

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.