protected function HandlerStackConfigurator::initializeMiddlewares in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Http/HandlerStackConfigurator.php \Drupal\Core\Http\HandlerStackConfigurator::initializeMiddlewares()
Ensures that the middlewares are initialized.
1 call to HandlerStackConfigurator::initializeMiddlewares()
- HandlerStackConfigurator::configure in core/
lib/ Drupal/ Core/ Http/ HandlerStackConfigurator.php - Configures the stack using services tagged as http_client_middleware.
File
- core/
lib/ Drupal/ Core/ Http/ HandlerStackConfigurator.php, line 61
Class
- HandlerStackConfigurator
- Defines a class for configuring middlewares on the http handler stack.
Namespace
Drupal\Core\HttpCode
protected function initializeMiddlewares() {
if (!isset($this->middlewares)) {
$this->middlewares = [];
foreach ($this->middlewareIds as $middleware_id) {
$middleware = $this->container
->get($middleware_id);
if (is_callable($middleware)) {
$this->middlewares[$middleware_id] = $middleware();
}
else {
throw new \InvalidArgumentException('Middlewares need to implement __invoke, see https://guzzle.readthedocs.org/en/latest/handlers-and-middleware.html for more information about middlewares.');
}
}
}
}