YoastSEO_Vendor\GuzzleHttp
Middleware::history() public Yoast 1.0
Middleware that pushes history data to an ArrayAccess container.
{} Это метод класса: Middleware{}
Хуков нет.
Возвращает
callable. Returns a function that accepts the next handler.
Использование
$result = Middleware::history( $container );
- $container(массив/\массивAccess) (обязательный) (передается по ссылке — &)
- Container to hold the history (by reference).
Код Middleware::history() Middleware::history Yoast 15.7
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 \YoastSEO_Vendor\GuzzleHttp\Promise\rejection_for($reason);
});
};
};
}