Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
importcollision.php
1<?php
3
4
22
24{
26 protected $typeId = null;
27 protected $entity = null;
28 protected $message = null;
29
39 {
40 if(!is_int($entityTypeId))
41 {
43 }
44 if(!EntityType::IsDefined($entityTypeId))
45 {
47 }
48
49 if(!is_int($typeId))
50 {
51 $typeId = (int)$typeId;
52 }
53
55 {
57 }
58
59 $this->setEntity($entity);
60
61 $this->entityTypeId = $entityTypeId;
62 $this->typeId = $typeId;
63 $this->message = $message;
64 }
65
71 public static function getCurrent($entityTypeId)
72 {
73 if(!EntityType::IsDefined($entityTypeId))
74 {
76 }
77
78 $criterion = new static();
79
80 return $criterion;
81 }
82
86 public function getEntity()
87 {
88 return $this->entity;
89 }
90
94 public function getTypeId()
95 {
96 return $this->typeId;
97 }
98
102 public function getMessage()
103 {
104 return $this->message;
105 }
106
110 public function getTypeName()
111 {
112 return EntityCollisionType::resolveName($this->typeId);
113 }
114
118 public function setEntity(Entity $entity)
119 {
120 $this->entity = $entity;
121 }
122
128 public function setCollision(EntityImport $item)
129 {
131 $entity = $item->getEntity();
132 if(!empty($entity))
133 {
134 $types = $this->getCollision($item);
135 if(count($types)>0)
136 {
137 foreach ($types as $typeId)
138 {
140 }
141 }
142 }
143 return new Result();
144 }
145
150 public function getCollision(EntityImport $item)
151 {
152 return array();
153 }
154
160 public function resolve(ImportBase $item)
161 {
162 return new Result();
163 }
164}
166{
167
173 public function resolve(ImportBase $item)
174 {
175 if(!($item instanceof OrderImport))
176 throw new ArgumentException("Item must be instanceof OrderImport");
177
178 $this->setCollision($item);
179
180 return new Result();
181 }
182
187 public function getCollision(EntityImport $item)
188 {
189 $result = array();
190
192 $settings = $item->getSettings();
193
195 $order = $item->getEntity();
196 if(!empty($order))
197 {
198 $collisionTypes = $settings->getCollisionResolve($item->getOwnerTypeId());
199
200 if(is_array($collisionTypes))
201 {
202 foreach ($collisionTypes as $collisionType)
203 {
204 switch($collisionType)
205 {
207 if($order->getField('STATUS_ID') == $settings->finalStatusIdFor($item->getOwnerTypeId()))
208 $result[] = EntityCollisionType::resolveID($collisionType);
209 break;
211 if($order->isPaid())
212 $result[] = EntityCollisionType::resolveID($collisionType);
213 break;
215 if($order->isShipped())
216 $result[] = EntityCollisionType::resolveID($collisionType);
217 break;
218 }
219 }
220 }
221 }
222
223 return $result;
224 }
225}
226
228{
234 public function resolve(ImportBase $item)
235 {
236 if(!($item instanceof PaymentImport))
237 throw new ArgumentException("Item must be instanceof PaymentImport");
238
239 $this->setCollision($item);
240
241 return new Result();
242 }
243
248 public function getCollision(EntityImport $item)
249 {
250 $result = array();
251
253 $payment = $item->getEntity();
254 if(!empty($payment))
255 {
256 if($payment->isPaid())
258 }
259
260 return $result;
261 }
262}
263
265{
271 public function resolve(ImportBase $item)
272 {
273 if(!($item instanceof ShipmentImport))
274 throw new ArgumentException("Item must be instanceof ShipmentImport");
275
276 $this->setCollision($item);
277
278 return new Result();
279 }
280
285 public function getCollision(EntityImport $item)
286 {
287 $result = array();
288
290 $shipment = $item->getEntity();
291 if(!empty($shipment))
292 {
293 if($shipment->isShipped())
295 }
296
297 return $result;
298 }
299}
300
302{
309 public function resolve(ImportBase $item)
310 {
311 if(!($item instanceof ProfileImport))
312 throw new ArgumentException("Item must be instanceof ProfileImport");
313
314 return new Result();
315 }
316}
setCollisions($tipeId, Sale\Internals\Entity $entity, $message=null)
addItem($entityTypeId, $typeId, Entity $entity, $message=null)