Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Promise.php

function Promise::__construct

Same name in this branch
  1. 11.1.x vendor/react/promise/src/Promise.php \React\Promise\Promise::__construct()
  2. 11.1.x vendor/guzzlehttp/promises/src/Promise.php \GuzzleHttp\Promise\Promise::__construct()

File

vendor/php-http/guzzle7-adapter/src/Promise.php, line 47

Class

Promise
Wrapper around Guzzle promises.

Namespace

Http\Adapter\Guzzle7

Code

public function __construct(PromiseInterface $promise, RequestInterface $request) {
    $this->request = $request;
    $this->state = self::PENDING;
    $this->promise = $promise->then(function ($response) {
        $this->response = $response;
        $this->state = self::FULFILLED;
        return $response;
    }, function ($reason) {
        $this->state = self::REJECTED;
        if ($reason instanceof HttplugException) {
            $this->exception = $reason;
        }
        elseif ($reason instanceof GuzzleExceptions\GuzzleException) {
            $this->exception = $this->handleException($reason);
        }
        elseif ($reason instanceof \Throwable) {
            $this->exception = new HttplugException\TransferException('Invalid exception returned from Guzzle7', 0, $reason);
        }
        else {
            $this->exception = new UnexpectedValueException('Reason returned from Guzzle7 must be an Exception');
        }
        throw $this->exception;
    });
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal