class HandlerStackConfigurator (View source)

Defines a class for configuring middlewares on the http handler stack.

The http_client service requires a handler stack to perform http requests. This is provided by the http_handler_stack service. Modules wishing to add additional middlewares to the handler stack can create services and tag them as http_client_middleware. Each service must contain an __invoke method that returns a closure which will serve as the middleware.

Properties

protected callable[] $middlewares

Array of middlewares to add to the handler stack.

protected string[] $middlewareIds

A list of used middleware service IDs.

protected ContainerInterface $container

The service container.

Methods

__construct(ContainerInterface $container, array $middleware_ids)

Constructs a new HandlerStackConfigurator object.

initializeMiddlewares()

Ensures that the middlewares are initialized.

configure(HandlerStack $handler_stack)

Configures the stack using services tagged as http_client_middleware.

Details

__construct(ContainerInterface $container, array $middleware_ids)

Constructs a new HandlerStackConfigurator object.

Parameters

ContainerInterface $container

The service container.

array $middleware_ids

The middleware IDs.

protected initializeMiddlewares()

Ensures that the middlewares are initialized.

configure(HandlerStack $handler_stack)

Configures the stack using services tagged as http_client_middleware.

Parameters

HandlerStack $handler_stack

The handler stack