public function JobQueue::getNextJob

Returns the next job from the queue.

Return value

\Drupal\tmgmt\JobInterface|null A job or NULL if the queue is empty.

1 call to JobQueue::getNextJob()
JobQueue::getNextUrl in src/JobQueue.php
Returns URL from the queue.

File

src/JobQueue.php, line 138

Class

JobQueue
Represents a job (checkout) queue.

Namespace

Drupal\tmgmt

Code

public function getNextJob() {
  while ($id = reset($this->queue)) {
    if ($job = Job::load($id)) {
      return $job;
    }
    else {

      // Stale job ID that can't be loaded, remove it from the queue.
      array_shift($this->queue);
    }
  }
}