function DatabaseQueue::delayItem
Same name in other branches
- 9 core/lib/Drupal/Core/Queue/DatabaseQueue.php \Drupal\Core\Queue\DatabaseQueue::delayItem()
- 10 core/lib/Drupal/Core/Queue/DatabaseQueue.php \Drupal\Core\Queue\DatabaseQueue::delayItem()
Overrides DelayableQueueInterface::delayItem
File
-
core/
lib/ Drupal/ Core/ Queue/ DatabaseQueue.php, line 178
Class
- DatabaseQueue
- Default queue implementation.
Namespace
Drupal\Core\QueueCode
public function delayItem($item, int $delay) {
// Only allow a positive delay interval.
if ($delay < 0) {
throw new \InvalidArgumentException('$delay must be non-negative');
}
try {
// Add the delay relative to the current time.
$expire = \Drupal::time()->getCurrentTime() + $delay;
// Update the expiry time of this item.
$update = $this->connection
->update(static::TABLE_NAME)
->fields([
'expire' => $expire,
])
->condition('item_id', $item->item_id);
return (bool) $update->execute();
} catch (\Exception $e) {
$this->catchException($e);
// If the table doesn't exist we should consider the item nonexistent.
return TRUE;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.