DatabaseQueue::createItem

public DatabaseQueue::createItem($data)

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 53

Class

DatabaseQueue
Default queue implementation.

Namespace

Drupal\Core\Queue

Code

public function createItem($data) {
  $try_again = FALSE;
  try {
    $id = $this->doCreateItem($data);
  }
  catch (\Exception $e) {
    // If there was an exception, try to create the table.
    if (!$try_again = $this->ensureTableExists()) {
      // If the exception happened for other reason than the missing table,
      // propagate the exception.
      throw $e;
    }
  }
  // Now that the table has been created, try again if necessary.
  if ($try_again) {
    $id = $this->doCreateItem($data);
  }
  return $id;
}
doc_Drupal
2016-10-29 08:59:49
Comments
Leave a Comment

Please login to continue.