3namespace Bitrix\Im\V2\Recent\Initializer;
5use Bitrix\Im\Model\RecentInitQueueTable;
6use Bitrix\Im\V2\Recent\Initializer\Queue\QueueItem;
7use Bitrix\Main\Application;
16 private function __construct()
22 self::$instance ??=
new static();
24 return self::$instance;
29 if ($queueItem ===
null)
34 if ($queueItem->id === 0)
36 return $this->
add($queueItem);
39 return $this->
update($queueItem);
44 if ($queueItem->id !== 0)
58 return $queueItem->
setId($id);
73 if ($queueItem->id === 0)
78 RecentInitQueueTable::update($queueItem->id, $this->getFieldsForAddOrUpdate($queueItem));
93 $lock = $this->
lock();
111 $row = RecentInitQueueTable::query()
117 return $row ===
false;
124 RecentInitQueueTable::delete($queueItem->id);
130 $row = RecentInitQueueTable::query()
132 ->where(
'IS_LOCKED',
false)
134 ->setOrder([
'ID' =>
'ASC'])
143 return QueueItem::createFromRow($row);
146 protected function lock(): bool
148 return Application::getConnection(RecentInitQueueTable::getConnectionName())
149 ->lock(self::LOCK_NAME, self::LOCK_TTL)
155 return Application::getConnection(RecentInitQueueTable::getConnectionName())->unlock(self::LOCK_NAME);
update(QueueItem $queueItem)
save(?QueueItem $queueItem)
getFieldsForMultiAdd(array $items)
add(QueueItem $queueItem)
getFieldsForAddOrUpdate(QueueItem $queueItem)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)