Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DatabaseQueue.php

function DatabaseQueue::doCreateItem

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

int|string 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.

1 call to DatabaseQueue::doCreateItem()
DatabaseQueue::createItem in core/lib/Drupal/Core/Queue/DatabaseQueue.php
Adds a queue item and store it directly to the queue.

File

core/lib/Drupal/Core/Queue/DatabaseQueue.php, line 85

Class

DatabaseQueue
Default queue implementation.

Namespace

Drupal\Core\Queue

Code

protected function doCreateItem($data) {
    $query = $this->connection
        ->insert(static::TABLE_NAME)
        ->fields([
        'name' => $this->name,
        'data' => serialize($data),
        // We cannot rely on \Drupal::time()->getRequestTime() because many
        // items might be created by a single request which takes longer than
        // 1 second.
'created' => \Drupal::time()->getCurrentTime(),
    ]);
    // Return the new serial ID, or FALSE on failure.
    return $query->execute();
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal