Automattic\WooCommerce\Vendor\GraphQL\Executor
ReferenceExecutor::promiseForAssocArray
Transform an associative array with Promises to a Promise which resolves to an associative array where all Promises were resolved.
Method of the class: ReferenceExecutor{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->promiseForAssocArray( $assoc ): Promise;
- $assoc(array) (required)
- .
ReferenceExecutor::promiseForAssocArray() ReferenceExecutor::promiseForAssocArray code WC 10.9.1
protected function promiseForAssocArray(array $assoc): Promise
{
$keys = array_keys($assoc);
$valuesAndPromises = array_values($assoc);
$promise = $this->exeContext->promiseAdapter->all($valuesAndPromises);
return $promise->then(static function ($values) use ($keys) {
$resolvedResults = [];
foreach ($values as $i => $value) {
$resolvedResults[$keys[$i]] = $value;
}
return static::fixResultsIfEmptyArray($resolvedResults);
});
}