mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-26 06:46:02 +03:00
Add hooks to helps promise completion with custom backend
This commit is contained in:
parent
9d150c7702
commit
1c143360ca
@ -126,6 +126,7 @@ class SyncPromiseAdapter implements PromiseAdapter
|
|||||||
*/
|
*/
|
||||||
public function wait(Promise $promise)
|
public function wait(Promise $promise)
|
||||||
{
|
{
|
||||||
|
$this->beforeWait($promise);
|
||||||
$dfdQueue = Deferred::getQueue();
|
$dfdQueue = Deferred::getQueue();
|
||||||
$promiseQueue = SyncPromise::getQueue();
|
$promiseQueue = SyncPromise::getQueue();
|
||||||
|
|
||||||
@ -135,6 +136,7 @@ class SyncPromiseAdapter implements PromiseAdapter
|
|||||||
) {
|
) {
|
||||||
Deferred::runQueue();
|
Deferred::runQueue();
|
||||||
SyncPromise::runQueue();
|
SyncPromise::runQueue();
|
||||||
|
$this->onWait($promise);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var SyncPromise $syncPromise */
|
/** @var SyncPromise $syncPromise */
|
||||||
@ -148,4 +150,22 @@ class SyncPromiseAdapter implements PromiseAdapter
|
|||||||
|
|
||||||
throw new InvariantViolation("Could not resolve promise");
|
throw new InvariantViolation("Could not resolve promise");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute just before starting to run promise completion
|
||||||
|
*
|
||||||
|
* @param Promise $promise
|
||||||
|
*/
|
||||||
|
protected function beforeWait(Promise $promise)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute while running promise completion
|
||||||
|
*
|
||||||
|
* @param Promise $promise
|
||||||
|
*/
|
||||||
|
protected function onWait(Promise $promise)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user