1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
temporary_storage.php
См. документацию.
1<?php
2
4{
5 const SESSION_DATA_KEY = 'SECURITY_TEMPORARY_STORAGE';
6 const DEFAULT_DATA_KEY = 'default';
7 protected $sessionData = array();
8
9 public function __construct($sessionKey = '', $forceFlush = false)
10 {
11 $this->initializeSessionData($sessionKey);
12 if($forceFlush)
13 {
14 $this->flushData();
15 }
16 }
17
18 /*
19 * Destroy data in all temporary storage
20 */
21 public static function clearAll()
22 {
23 unset($_SESSION[self::SESSION_DATA_KEY]);
24 }
25
29 public function clearKey($key)
30 {
31 unset($this->sessionData[$key]);
32 }
33
38 protected function initializeSessionData($sessionKey = '')
39 {
40 if(!is_string($sessionKey) || !$sessionKey)
41 $sessionKey = self::DEFAULT_DATA_KEY;
42
43 $this->sessionData = &$_SESSION[self::SESSION_DATA_KEY][$sessionKey];
44 if(!is_array($this->sessionData))
45 {
46 $this->sessionData = array();
47 }
48 return true;
49 }
50
51 public function flushData()
52 {
53 $this->sessionData = array();
54 }
55
60 public function setData($key, $value)
61 {
62 $this->sessionData[$key] = $value;
63 }
64
69 public function getString($key)
70 {
71 if(isset($this->sessionData[$key]) && is_string($this->sessionData[$key]))
72 {
73 return $this->sessionData[$key];
74 }
75 else
76 {
77 return '';
78 }
79 }
80
85 public function getInt($key)
86 {
87 if(isset($this->sessionData[$key]) && is_numeric($this->sessionData[$key]))
88 {
89 return $this->sessionData[$key];
90 }
91 else
92 {
93 return 0;
94 }
95 }
96
101 public function getBool($key)
102 {
103 if(isset($this->sessionData[$key]) && is_bool($this->sessionData[$key]))
104 {
105 return $this->sessionData[$key];
106 }
107 else
108 {
109 return false;
110 }
111 }
112
117 public function isEmpty($key)
118 {
119 if(!isset($this->sessionData[$key]) || empty($this->sessionData[$key]))
120 {
121 return true;
122 }
123 else
124 {
125 return false;
126 }
127 }
128
133 public function isExists($key)
134 {
135 return isset($this->sessionData[$key]);
136 }
137
141 public function increment($key)
142 {
143 $this->setData($key, $this->getInt($key) + 1);
144 }
145
149 public function decrement($key)
150 {
151 $this->setData($key, $this->getInt($key) - 1);
152 }
153
158 public function getArray($key)
159 {
160 if(isset($this->sessionData[$key]) && is_array($this->sessionData[$key]))
161 {
162 return $this->sessionData[$key];
163 }
164 else
165 {
166 return array();
167 }
168 }
169
174 public function getArrayPop($key)
175 {
176 if(isset($this->sessionData[$key]) && is_array($this->sessionData[$key]))
177 {
178 return array_pop($this->sessionData[$key]);
179 }
180 else
181 {
182 return null;
183 }
184 }
185
190 public function pushToArray($key, $value)
191 {
192 if(isset($this->sessionData[$key]) && is_array($this->sessionData[$key]))
193 {
194 array_push($this->sessionData[$key], $value);
195 }
196 else
197 {
198 $this->sessionData[$key] = array($value);
199 }
200 }
201}
initializeSessionData($sessionKey='')
Определения temporary_storage.php:38
const DEFAULT_DATA_KEY
Определения temporary_storage.php:6
__construct($sessionKey='', $forceFlush=false)
Определения temporary_storage.php:9
pushToArray($key, $value)
Определения temporary_storage.php:190
setData($key, $value)
Определения temporary_storage.php:60
static clearAll()
Определения temporary_storage.php:21
const SESSION_DATA_KEY
Определения temporary_storage.php:5
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if(empty($signedUserToken)) $key
Определения quickway.php:257