Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
collectableentity.php
1<?php
3
7
12abstract class CollectableEntity
13 extends Internals\Entity
14{
16 protected $collection;
17
18 protected $internalIndex = null;
19
20 protected $isClone = false;
21
29 protected function onFieldModify($name, $oldValue, $value)
30 {
31 $collection = $this->getCollection();
32 return $collection->onItemModify($this, $name, $oldValue, $value);
33 }
34
39 {
40 $this->collection = $collection;
41 }
42
46 public function getCollection()
47 {
48 return $this->collection;
49 }
50
55 public function delete()
56 {
57 $collection = $this->getCollection();
58 if (!$collection)
59 {
60 throw new Main\ObjectNotFoundException('Entity "CollectableEntity" not found');
61 }
62
64 $collection->deleteItem($this->getInternalIndex());
65
66 return new Result();
67 }
68
75 public function setInternalIndex($index)
76 {
77 $this->internalIndex = $index;
78 }
79
83 public function getInternalIndex()
84 {
86 }
87
92 public function isStartField($isMeaningfulField = false)
93 {
94 $parent = $this->getCollection();
95 if ($parent == null)
96 return false;
97
98 return $parent->isStartField($isMeaningfulField);
99 }
100
104 public function clearStartField()
105 {
106 $parent = $this->getCollection();
107 if ($parent == null)
108 return false;
109
110 return $parent->clearStartField();
111 }
112
116 public function hasMeaningfulField()
117 {
118 $parent = $this->getCollection();
119 if ($parent == null)
120 return false;
121
122 return $parent->hasMeaningfulField();
123 }
124
125 public function doFinalAction($hasMeaningfulField = false)
126 {
127 $parent = $this->getCollection();
128 if ($parent == null)
129 {
130 return false;
131 }
132
133 return $parent->doFinalAction($hasMeaningfulField);
134 }
135
140 public function setMathActionOnly($value = false)
141 {
142 $parent = $this->getCollection();
143 if ($parent == null)
144 {
145 return false;
146 }
147
148 return $parent->setMathActionOnly($value);
149 }
150
154 public function isMathActionOnly()
155 {
156 $parent = $this->getCollection();
157 if ($parent == null)
158 return false;
159
160 return $parent->isMathActionOnly();
161 }
162
166 public function isClone()
167 {
168 return $this->isClone;
169 }
170
177 public function createClone(\SplObjectStorage $cloneEntity)
178 {
179 if ($this->isClone() && $cloneEntity->contains($this))
180 {
181 return $cloneEntity[$this];
182 }
183
184 $collectableEntity = clone $this;
185 $collectableEntity->isClone = true;
186
188 if ($fields = $this->fields)
189 {
190 $collectableEntity->fields = $fields->createClone($cloneEntity);
191 }
192
193 if (!$cloneEntity->contains($this))
194 {
195 $cloneEntity[$this] = $collectableEntity;
196 }
197
198 if ($collection = $this->getCollection())
199 {
200 if (!$cloneEntity->contains($collection))
201 {
202 $cloneEntity[$collection] = $collection->createClone($cloneEntity);
203 }
204
205 if ($cloneEntity->contains($collection))
206 {
207 $collectableEntity->collection = $cloneEntity[$collection];
208 }
209 }
210
211 return $collectableEntity;
212 }
213}
setCollection(EntityCollection $collection)