Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
packagetrait.php
1<?php
2
4
5
8
9trait PackageTrait
10{
16 protected static function load(ImportBase $item, array $fields, $order=null)
17 {
18 if($item->getOwnerTypeId() <> static::getParentEntityTypeId())
19 {
20 if($item instanceof EntityImport)
21 {
22 $item->setParentEntity($order);
23 }
24 }
25
26 $item->load($fields);
27 }
28
33 protected function getProductsItems(array $fields)
34 {
35 return (isset($fields['ITEMS']) && is_array($fields['ITEMS'])) ? $fields['ITEMS']:array();
36 }
37
43 protected function hasDocumentByTypeId($type_id, array $documents)
44 {
45 $documentImport = $this->getDocumentByTypeId($type_id, $documents);
46
47 return ($documentImport !== null);
48 }
49
55 protected function getDocumentByTypeId($type_id, array $documents)
56 {
57 foreach($documents as $document)
58 {
59 if(DocumentType::isDefined($type_id))
60 {
61 if($document->getTypeId() == $type_id)
62 {
63 return $document;
64 }
65 }
66 }
67
68 return null;
69 }
70
76 protected function getEntityByTypeId($type_id, array $items)
77 {
78 foreach($items as $item)
79 {
80 if(EntityType::isDefined($type_id))
81 {
82 if($item->getOwnerTypeId() == $type_id)
83 {
84 return $item;
85 }
86 }
87 }
88
89 return null;
90 }
91
96 protected function deliveryServiceExists(array $list)
97 {
98 $deliveryItem = $this->getDeliveryServiceItem($list);
99
100 return !($deliveryItem === null);
101 }
102}