Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
servicequeue.php
1<?php
2
4
6
7final class ServiceQueue
8{
10 private static $instancePool = [];
11
13 private $head;
14
16 private $values;
17
18 public static function getInstance(string $type) : self
19 {
20 if(!array_key_exists($type,static::$instancePool))
21 {
22 static::$instancePool[$type] = new static($type);
23 }
24 return static::$instancePool[$type];
25 }
26
27 private function __construct(string $type)
28 {
29 $this->values = Internals\ServiceQueueTable::getList([
30 'select' => ['ID','SERVICE_TYPE','CLIENT_ID','TYPE'],
31 'filter' => ['=TYPE'=> $type ],
32 'order' => ['SORT' => 'DESC']
33 ]);
34 $this->head = $this->getHead();
35 }
36 private function __clone()
37 {}
38
43 public function getHead()
44 {
45 return $this->head = ($this->head? $this->head : $this->values->fetch());
46 }
47
52 public function removeHead()
53 {
54 if($this->head)
55 {
56 Internals\ServiceQueueTable::delete($this->head['ID']);
57 unset($this->head);
58 }
59 }
60}