You are here

public function SimplesitemapQueue::yieldItem in Simple XML sitemap 8.3

Same name and namespace in other branches
  1. 4.x src/Queue/SimpleSitemapQueue.php \Drupal\simple_sitemap\Queue\SimpleSitemapQueue::yieldItem()

Gets a simple_sitemap queue item in a very efficient way.

Return value

\Generator A queue item object with at least the following properties:

  • data: the same as what what passed into createItem().
  • item_id: the unique ID returned from createItem().
  • created: timestamp when the item was put into the queue.

See also

\Drupal\Core\Queue\QueueInterface::claimItem

File

src/Queue/SimplesitemapQueue.php, line 64

Class

SimplesitemapQueue
Class SimplesitemapQueue @package Drupal\simple_sitemap\Queue

Namespace

Drupal\simple_sitemap\Queue

Code

public function yieldItem() {
  try {
    $query = $this->connection
      ->query('SELECT data, item_id FROM {queue} q WHERE name = :name ORDER BY item_id ASC', [
      ':name' => $this->name,
    ]);
    while ($item = $query
      ->fetchObject()) {
      $item->data = unserialize($item->data);
      (yield $item);
    }
  } catch (\Exception $e) {
    $this
      ->catchException($e);
  }
}