Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Middleware.php

function Middleware::history

Middleware that pushes history data to an ArrayAccess container.

Parameters

array|\ArrayAccess<int, array> $container Container to hold the history (by reference).:

Return value

callable(callable): callable Returns a function that accepts the next handler.

Throws

\InvalidArgumentException if container is not an array or ArrayAccess.

File

vendor/guzzlehttp/guzzle/src/Middleware.php, line 88

Class

Middleware
Functions used to create and wrap handlers with handler middleware.

Namespace

GuzzleHttp

Code

public static function history(&$container) : callable {
    if (!\is_array($container) && !$container instanceof \ArrayAccess) {
        throw new \InvalidArgumentException('history container must be an array or object implementing ArrayAccess');
    }
    return static function (callable $handler) use (&$container) : callable {
        return static function (RequestInterface $request, array $options) use ($handler, &$container) {
            return $handler($request, $options)->then(static function ($value) use ($request, &$container, $options) {
                $container[] = [
                    'request' => $request,
                    'response' => $value,
                    'error' => null,
                    'options' => $options,
                ];
                return $value;
            }, static function ($reason) use ($request, &$container, $options) {
                $container[] = [
                    'request' => $request,
                    'response' => null,
                    'error' => $reason,
                    'options' => $options,
                ];
                return P\Create::rejectionFor($reason);
            });
        };
    };
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal