You are here

public function DatabaseQueue::createItem in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Queue/DatabaseQueue.php \Drupal\Core\Queue\DatabaseQueue::createItem()

Adds a queue item and store it directly to the queue.

Parameters

$data: Arbitrary data to be associated with the new task in the queue.

Return value

A unique ID if the item was successfully created and was (best effort) added to the queue, otherwise FALSE. We don't guarantee the item was committed to disk etc, but as far as we know, the item is now in the queue.

Overrides QueueInterface::createItem

File

core/lib/Drupal/Core/Queue/DatabaseQueue.php, line 52
Contains \Drupal\Core\Queue\DatabaseQueue.

Class

DatabaseQueue
Default queue implementation.

Namespace

Drupal\Core\Queue

Code

public function createItem($data) {
  $query = $this->connection
    ->insert('queue')
    ->fields(array(
    'name' => $this->name,
    'data' => serialize($data),
    // We cannot rely on REQUEST_TIME because many items might be created
    // by a single request which takes longer than 1 second.
    'created' => time(),
  ));

  // Return the new serial ID, or FALSE on failure.
  return $query
    ->execute();
}