You are here

private function EachPromise::addPending in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/guzzlehttp/promises/src/EachPromise.php \GuzzleHttp\Promise\EachPromise::addPending()
1 call to EachPromise::addPending()
EachPromise::refillPending in vendor/guzzlehttp/promises/src/EachPromise.php

File

vendor/guzzlehttp/promises/src/EachPromise.php, line 134

Class

EachPromise
Represents a promise that iterates over many promises and invokes side-effect functions in the process.

Namespace

GuzzleHttp\Promise

Code

private function addPending() {
  if (!$this->iterable || !$this->iterable
    ->valid()) {
    return false;
  }
  $promise = promise_for($this->iterable
    ->current());
  $idx = $this->iterable
    ->key();
  $this->pending[$idx] = $promise
    ->then(function ($value) use ($idx) {
    if ($this->onFulfilled) {
      call_user_func($this->onFulfilled, $value, $idx, $this->aggregate);
    }
    $this
      ->step($idx);
  }, function ($reason) use ($idx) {
    if ($this->onRejected) {
      call_user_func($this->onRejected, $reason, $idx, $this->aggregate);
    }
    $this
      ->step($idx);
  });
  return true;
}