1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
fields.php
См. документацию.
1<?php
2namespace Bitrix\Sale\Internals;
3
4class Fields
5 implements \ArrayAccess, \Iterator, \Countable
6{
8 protected $values = array();
9
11 protected $changedValues = array();
12
14 private $originalValues = array();
15
17 private $customFields = array();
18
20 protected $isClone = false;
21
22
23 public function __construct(array $values = null)
24 {
25 if ($values !== null)
26 $this->values = $values;
27 }
28
33 public function isChanged($name)
34 {
35 return isset($this->changedValues[$name]);
36 }
37
44 public function get($name)
45 {
46 if (isset($this->values[$name]))
47 {
48 return $this->values[$name];
49 }
50
51 return null;
52 }
53
57 public function markCustom(string $field)
58 {
59 $this->customFields[$field] = true;
60 }
61
66 public function isMarkedCustom(string $field) : bool
67 {
68 if (!isset($this->customFields[$field]))
69 {
70 return false;
71 }
72
73 return $this->customFields[$field];
74 }
75
79 public function unmarkCustom(string $field)
80 {
81 $this->customFields[$field] = false;
82 }
83
89 public function set($name, $value)
90 {
91 if ($this->markChanged($name, $value))
92 {
93 $this->values[$name] = $value;
94 return true;
95 }
96
97 return false;
98 }
99
107 public function init($name, $value)
108 {
109 $this->values[$name] = $value;
110 return true;
111 }
112
113
114 public function clear()
115 {
116 $this->values = array();
117 $this->clearChanged();
118 }
119
120 public function clearChanged()
121 {
122 $this->changedValues = array();
123 $this->originalValues = array();
124 }
125
129 public function getValues()
130 {
131 return $this->values;
132 }
133
138 public function getOriginalValues()
139 {
140 return $this->originalValues;
141 }
142
146 public function setValues(array $values)
147 {
148 foreach ($values as $name => $value)
149 $this->set($name, $value);
150 }
151
155 public function resetValues(array $values)
156 {
157 $this->values = array();
158 if ($values !== null)
159 $this->values = $values;
160 }
161
167 protected function markChanged($name, $value)
168 {
169 $originalValuesIndex = array();
170 if (!empty($this->originalValues))
171 {
172 foreach(array_keys($this->originalValues) as $originalKey)
173 {
174 $originalValuesIndex[$originalKey] = true;
175 }
176 }
177
178 $oldValue = $this->get($name);
179 if ($oldValue != $value || ($oldValue === null && $value !== null))
180 {
181 if (!isset($originalValuesIndex[$name]))
182 {
183 $this->originalValues[$name] = $this->get($name);
184 }
185 elseif ($this->originalValues[$name] == $value)
186 {
187 unset($this->changedValues[$name]);
188 unset($this->originalValues[$name]);
189 return true;
190 }
191
192 $this->changedValues[$name] = true;
193 return true;
194 }
195
196 return false;
197 }
198
202 public function getChangedKeys()
203 {
204 return array_keys($this->changedValues);
205 }
206
210 public function getChangedValues()
211 {
212 $r = array();
213 foreach ($this->values as $k => $v)
214 {
215 if (isset($this->changedValues[$k]))
216 $r[$k] = $v;
217 }
218 return $r;
219 }
220
224 #[\ReturnTypeWillChange]
225 public function current()
226 {
227 return current($this->values);
228 }
229
233 public function next(): void
234 {
235 next($this->values);
236 }
237
241 #[\ReturnTypeWillChange]
242 public function key()
243 {
244 return key($this->values);
245 }
246
250 public function valid(): bool
251 {
252 $key = $this->key();
253 return ($key != null);
254 }
255
259 public function rewind(): void
260 {
261 reset($this->values);
262 }
263
271 public function offsetExists($offset): bool
272 {
273 return isset($this->values[$offset]) || array_key_exists($offset, $this->values);
274 }
275
283 #[\ReturnTypeWillChange]
284 public function offsetGet($offset)
285 {
286 return $this->get($offset);
287 }
288
295 public function offsetSet($offset, $value): void
296 {
297 $this->set($offset, $value);
298 }
299
305 public function offsetUnset($offset): void
306 {
307 unset($this->values[$offset]);
308 if (isset($this->changedValues[$offset]))
309 unset($this->changedValues[$offset]);
310 }
311
315 public function count(): int
316 {
317 return count($this->values);
318 }
319
326 public function createClone(\SplObjectStorage $cloneEntity): Fields
327 {
328 if ($this->isClone() && $cloneEntity->contains($this))
329 {
330 return $cloneEntity[$this];
331 }
332
333 $fieldsClone = clone $this;
334 $fieldsClone->isClone = true;
335
336 if (!$cloneEntity->contains($this))
337 {
338 $cloneEntity[$this] = $fieldsClone;
339 }
340
341 return $fieldsClone;
342 }
343
347 public function isClone()
348 {
349 return $this->isClone;
350 }
351}
getChangedKeys()
Определения fields.php:202
isMarkedCustom(string $field)
Определения fields.php:66
resetValues(array $values)
Определения fields.php:155
createClone(\SplObjectStorage $cloneEntity)
Определения fields.php:326
getOriginalValues()
Определения fields.php:138
init($name, $value)
Определения fields.php:107
offsetUnset($offset)
Определения fields.php:305
offsetExists($offset)
Определения fields.php:271
offsetGet($offset)
Определения fields.php:284
__construct(array $values=null)
Определения fields.php:23
isChanged($name)
Определения fields.php:33
unmarkCustom(string $field)
Определения fields.php:79
getChangedValues()
Определения fields.php:210
markCustom(string $field)
Определения fields.php:57
markChanged($name, $value)
Определения fields.php:167
offsetSet($offset, $value)
Определения fields.php:295
clearChanged()
Определения fields.php:120
setValues(array $values)
Определения fields.php:146
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$name
Определения menu_edit.php:35
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$k
Определения template_pdf.php:567