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

Breadcrumb

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

function Promise::cancel

Same name in this branch
  1. 11.1.x vendor/guzzlehttp/promises/src/Promise.php \GuzzleHttp\Promise\Promise::cancel()

Overrides PromiseInterface::cancel

File

vendor/react/promise/src/Promise.php, line 110

Class

Promise
@template T @template-implements PromiseInterface<T>

Namespace

React\Promise

Code

public function cancel() : void {
    $this->cancelled = true;
    $canceller = $this->canceller;
    $this->canceller = null;
    $parentCanceller = null;
    if (null !== $this->result) {
        // Forward cancellation to rejected promise to avoid reporting unhandled rejection
        if ($this->result instanceof RejectedPromise) {
            $this->result
                ->cancel();
        }
        // Go up the promise chain and reach the top most promise which is
        // itself not following another promise
        $root = $this->unwrap($this->result);
        // Return if the root promise is already resolved or a
        // FulfilledPromise or RejectedPromise
        if (!$root instanceof self || null !== $root->result) {
            return;
        }
        $root->requiredCancelRequests--;
        if ($root->requiredCancelRequests <= 0) {
            $parentCanceller = [
                $root,
                'cancel',
            ];
        }
    }
    if (null !== $canceller) {
        $this->call($canceller);
    }
    // For BC, we call the parent canceller after our own canceller
    if ($parentCanceller) {
        $parentCanceller();
    }
}

API Navigation

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