Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
filterabledictionary.php
1<?php
2namespace Bitrix\Main\Type;
3
5 extends Dictionary
6{
10 protected $name;
11
15 protected $arRawValues = array();
16
20 protected $arFilters = array();
21
27 public function __construct(array $values, $name = null)
28 {
29 $this->values = $this->arRawValues = $values;
30 $this->name = $name;
31 }
32
33 public function addFilter(IDictionaryFilter $filter)
34 {
35 $this->values = $filter->filterArray($this->values, $this->name);
36 $this->arFilters[] = $filter;
37 }
38
45 public function getRaw($name)
46 {
47 if (isset($this->arRawValues[$name]) || array_key_exists($name, $this->arRawValues))
48 return $this->arRawValues[$name];
49
50 return null;
51 }
52
56 public function offsetSet($offset, $value)
57 {
58 $this->values[$offset] = $this->arRawValues[$offset] = $value;
59 foreach ($this->arFilters as $filter)
60 $this->values[$offset] = $filter->filter($this->values[$offset], $this->name."[".$offset."]", $this->values);
61 }
62
66 public function offsetUnset($offset): void
67 {
68 unset($this->values[$offset]);
69 unset($this->arRawValues[$offset]);
70 }
71}