You are here

public static function Middleware::history in Auth0 Single Sign On 8.2

Middleware that pushes history data to an ArrayAccess container.

Parameters

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

Return value

callable Returns a function that accepts the next handler.

Throws

\InvalidArgumentException if container is not an array or ArrayAccess.

3 calls to Middleware::history()
Auth0Test::testThatRenewTokensSucceeds in vendor/auth0/auth0-php/tests/Auth0Test.php
Test that renewTokens succeeds with non-empty access_token and refresh_token stored.
MockApi::__construct in vendor/auth0/auth0-php/tests/MockApi.php
MockApi constructor.
RequestBuilderTest::testThatBooleanFormParamsAreAdded in vendor/auth0/auth0-php/tests/API/Helpers/RequestBuilderTest.php

File

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

Class

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

Namespace

GuzzleHttp

Code

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