public function UniqueQueueItem::addItem in TMGMT Extension Suite 8
Same name and namespace in other branches
- 8.3 src/Utils/UniqueQueueItem.php \Drupal\tmgmt_extension_suit\Utils\UniqueQueueItem::addItem()
- 8.2 src/Utils/UniqueQueueItem.php \Drupal\tmgmt_extension_suit\Utils\UniqueQueueItem::addItem()
Adds item into a queue only if it's unique.
Parameters
string $queueName: Queue name.
array $data: Data to be added.
File
- src/
Utils/ UniqueQueueItem.php, line 45 - Contains QueueUniqueItem service class.
Class
Namespace
Drupal\tmgmt_extension_suit\UtilsCode
public function addItem($queueName, $data) {
$serializedData = serialize($data);
$count = $this->databaseConnection
->select('queue', 'q')
->condition('q.name', $queueName)
->condition('q.data', $serializedData)
->countQuery()
->execute()
->fetchField();
if ($count != 0) {
return;
}
$result = $this->queueFactory
->get($queueName)
->createItem($data);
if ($result) {
$this->logger
->info('New unique item has been added into the "@queue" queue. Serialized queue item: @item.', [
'@queue' => $queueName,
'@item' => $serializedData,
]);
}
}