Ejemplo n.º 1
0
 /**
  * Fulfill promise.
  *
  * @throws \Exception from on fulfill handler.
  */
 public function fulfill()
 {
     $this->state = Promise::FULFILLED;
     $response = $this->responseBuilder->getResponse();
     $response->getBody()->seek(0);
     while (count($this->onFulfilled) > 0) {
         $callback = array_shift($this->onFulfilled);
         $response = call_user_func($callback, $response);
     }
     if ($response instanceof ResponseInterface) {
         $this->responseBuilder->setResponse($response);
     }
 }
Ejemplo n.º 2
0
 /**
  * Fulfill promise.
  */
 public function fulfill()
 {
     $this->state = Promise::FULFILLED;
     $response = $this->responseBuilder->getResponse();
     try {
         $response->getBody()->seek(0);
     } catch (\RuntimeException $e) {
         $exception = new Exception\TransferException($e->getMessage(), $e->getCode(), $e);
         $this->reject($exception);
         return;
     }
     while (count($this->onFulfilled) > 0) {
         $callback = array_shift($this->onFulfilled);
         $response = call_user_func($callback, $response);
     }
     if ($response instanceof ResponseInterface) {
         $this->responseBuilder->setResponse($response);
     }
 }