Build a MultiTransferException if needed
array $requestsInScope All requests in the previous scope:
protected function buildMultiTransferException(array $requestsInScope) {
if (empty($this->exceptions)) {
return null;
}
// Keep a list of all requests, and remove errored requests from the list
$store = new \SplObjectStorage();
foreach ($requestsInScope as $request) {
$store
->attach($request);
}
$multiException = new MultiTransferException('Errors during multi transfer');
while ($e = array_shift($this->exceptions)) {
$multiException
->add($e['exception']);
if (isset($e['request'])) {
$multiException
->addFailedRequest($e['request']);
// Remove from the total list so that it becomes a list of successful requests
unset($store[$e['request']]);
}
}
// Add successful requests
foreach ($store as $request) {
$multiException
->addSuccessfulRequest($request);
}
return $multiException;
}