}
});
}
}
public function isEmpty()
{
return !$this->queue;
}
public function add(callable $task)
{
$this->queue[] = $task;
}
public function run()
{
/** @var callable $task */
while ($task = array_shift($this->queue)) {
$task();
}
}
/**
* The task queue will be run and exhausted by default when the process
* exits IFF the exit is not the result of a PHP E_ERROR error.
*
* You can disable running the automatic shutdown of the queue by calling
* this function. If you disable the task queue shutdown process, then you
* MUST either run the task queue (as a result of running your event loop
* or manually using the run() method) or wait on each outstanding promise.
*
* Note: This shutdown will occur before any destructors are triggered.
*/
public function disableShutdown()
{
$this->enableShutdown = false;
}
}

*
* @return Prismic::SearchForm a clone of the SearchForm object with the new orderings parameter added
*/
public function orderings()
{
if (func_num_args() == 0) return $this;
$orderings = "[" . join(",", array_map(function($order) { return preg_replace('/(^\[|\]$)/', '', $order); }, func_get_args())) . "]";
return $this->set("orderings", $orderings);
}
/**
* Submit the current API call, and unmarshalls the result into PHP objects.
*
* @return Prismic::Response the result of the call
*
* \throws RuntimeException
*/
public function submit()
{
return $this->submit_raw();
}
/**
* Get the result count for this form
*
* This uses a copy of the SearchForm with a page size of 1 (the smallest
* allowed) since all we care about is one of the returned non-result
* fields.
*
* @return int Total number of results
*
* \throws RuntimeException
*/
public function count()
{
return $this->pageSize(1)->submit_raw()->total_results_size;
}
/**
* Set the query's predicates themselves.