Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/seo/lib/businesssuite/utils/ |
Upload File : |
<?php namespace Bitrix\Seo\BusinessSuite\Utils; use Bitrix\Seo\BusinessSuite\Internals; final class ServiceQueue { /** @var self[] $queue*/ private static $instancePool = []; /** @var array $head */ private $head; /**@var \Bitrix\Main\ORM\Query\Result $values*/ private $values; public static function getInstance(string $type) : self { if(!array_key_exists($type,static::$instancePool)) { static::$instancePool[$type] = new static($type); } return static::$instancePool[$type]; } private function __construct(string $type) { $this->values = Internals\ServiceQueueTable::getList([ 'select' => ['ID','SERVICE_TYPE','CLIENT_ID','TYPE'], 'filter' => ['=TYPE'=> $type ], 'order' => ['SORT' => 'DESC'] ]); $this->head = $this->getHead(); } private function __clone() {} /** * return head of sequence * @return array|false|mixed */ public function getHead() { return $this->head = ($this->head? $this->head : $this->values->fetch()); } /** * remove head of sequence * @throws \Exception */ public function removeHead() { if($this->head) { Internals\ServiceQueueTable::delete($this->head['ID']); unset($this->head); } } }