public function Memory::createItem in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Queue/Memory.php \Drupal\Core\Queue\Memory::createItem()
- 10 core/lib/Drupal/Core/Queue/Memory.php \Drupal\Core\Queue\Memory::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/ Memory.php, line 44
Class
- Memory
- Static queue implementation.
Namespace
Drupal\Core\QueueCode
public function createItem($data) {
$item = new \stdClass();
$item->item_id = $this->idSequence++;
$item->data = $data;
$item->created = \Drupal::time()
->getCurrentTime();
$item->expire = 0;
$this->queue[$item->item_id] = $item;
return $item->item_id;
}