Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
valuesqueue.php
1<?php
8
10{
12 protected $db_values = array();
13
15 protected static $queues = array();
16
25 public static function getInstance($key)
26 {
27 if (!isset(self::$queues[$key]))
28 self::$queues[$key] = new ValuesQueue();
29 return self::$queues[$key];
30 }
31
37 public static function deleteAll()
38 {
39 foreach (self::$queues as $queue)
40 {
41 $queue->db_values = array();
42 }
43 }
44
53 public function get($iblockId)
54 {
55 $ids = array();
56 foreach ($this->db_values[$iblockId] as $id => $loaded)
57 {
58 if ($loaded === false)
59 $ids[$id] = intval($id);
60 }
61 return $ids;
62 }
63
73 public function set($iblockId, $values)
74 {
75 foreach ($this->db_values[$iblockId] as $id => $loaded)
76 {
77 if (isset($values[$id]))
78 $this->db_values[$iblockId][$id] = $values[$id];
79 else
80 $this->db_values[$iblockId][$id] = array();
81 }
82 }
83
92 public function addElement($iblockId, $id)
93 {
94 if (!isset($this->db_values[$iblockId]))
95 {
96 $this->db_values[$iblockId] = array();
97 }
98
99 if (!isset($this->db_values[$iblockId][$id]))
100 {
101 $this->db_values[$iblockId][$id] = false;
102 }
103 }
104
113 public function deleteElement($iblockId, $id)
114 {
115 unset($this->db_values[$iblockId][$id]);
116 }
117
128 public function getElement($iblockId, $id)
129 {
130 return $this->db_values[$iblockId][$id];
131 }
132
143 public function setElement($iblockId, $id, $value)
144 {
145 $this->db_values[$iblockId][$id] = $value;
146 }
147}