Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
queuefactory.php
1<?php
2
4
6{
7 private static array $cache = [];
8
9 public function getById(int $queueId): ?Queue
10 {
11 if (!array_key_exists($queueId, self::$cache))
12 {
13 if ($queueName = QueueRegistry::getNameById($queueId))
14 {
15 self::$cache[$queueId] = new Queue($queueId, $queueName);
16 }
17 else
18 {
19 self::$cache[$queueId] = null;
20 }
21 }
22
23 return self::$cache[$queueId];
24 }
25
26 public function getByName(string $queueName): ?Queue
27 {
28 if ($queueId = QueueRegistry::getIdByName($queueName))
29 {
30 if (!array_key_exists($queueId, self::$cache))
31 {
32 self::$cache[$queueId] = new Queue($queueId, $queueName);
33 }
34 }
35 else
36 {
37 self::$cache[$queueId] = null;
38 }
39
40 return self::$cache[$queueId];
41 }
42}