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

Breadcrumb

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

function Create::promiseFor

Creates a promise for a value if the value is not a promise.

Parameters

mixed $value Promise or value.:

2 calls to Create::promiseFor()
EachPromise::addPending in vendor/guzzlehttp/promises/src/EachPromise.php
Promise::then in vendor/guzzlehttp/promises/src/Promise.php
Appends fulfillment and rejection handlers to the promise, and returns a new promise resolving to the return value of the called handler.

File

vendor/guzzlehttp/promises/src/Create.php, line 14

Class

Create

Namespace

GuzzleHttp\Promise

Code

public static function promiseFor($value) : PromiseInterface {
    if ($value instanceof PromiseInterface) {
        return $value;
    }
    // Return a Guzzle promise that shadows the given promise.
    if (is_object($value) && method_exists($value, 'then')) {
        $wfn = method_exists($value, 'wait') ? [
            $value,
            'wait',
        ] : null;
        $cfn = method_exists($value, 'cancel') ? [
            $value,
            'cancel',
        ] : null;
        $promise = new Promise($wfn, $cfn);
        $value->then([
            $promise,
            'resolve',
        ], [
            $promise,
            'reject',
        ]);
        return $promise;
    }
    return new FulfilledPromise($value);
}

API Navigation

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