Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
propertyvalue.php
1<?php
2
3namespace Bitrix\Sale;
4
7
13{
19 protected static function extractPaySystemIdList(Entity $order)
20 {
21 if (!$order instanceof Order)
22 {
23 return [];
24 }
25
26 return $order->getPaySystemIdList();
27 }
28
35 protected static function extractDeliveryIdList(Entity $order)
36 {
37 if (!$order instanceof Order)
38 {
39 return [];
40 }
41
42 return $order->getDeliveryIdList();
43 }
44
45 protected static function extractTpLandingIdList(Entity $order) : array
46 {
47 if (!$order instanceof Order)
48 {
49 return [];
50 }
51
52 return $order->getTradeBindingCollection()->getTradingPlatformIdList();
53 }
54
55 protected static function extractTradingPlatformIdList(Entity $order): array
56 {
57 if (!$order instanceof Order)
58 {
59 return [];
60 }
61
62 return $order->getTradeBindingCollection()->getTradingPlatformIdList();
63 }
64
72 protected function update()
73 {
75 $propertyCollection = $this->getCollection();
76
78 if (!$order = $propertyCollection->getOrder())
79 {
80 throw new Main\ObjectNotFoundException('Entity "Order" not found');
81 }
82
83 $logFields = [];
84 if ($order->getId() > 0)
85 {
86 $logFields = $this->getLogFieldsForUpdate();
87 }
88
89 $result = parent::update();
90 if ($result->isSuccess())
91 {
92 if ($order->getId() > 0)
93 {
94 $this->addToLog('PROPERTY_UPDATE', $logFields);
95 }
96 }
97
98 return $result;
99 }
100
104 private function getLogFieldsForUpdate()
105 {
106 $logFields = [
107 "NAME" => $this->getField("NAME"),
108 "VALUE" => $this->getField("VALUE"),
109 "CODE" => $this->getField("CODE"),
110 ];
111
112 $fields = $this->getFields();
113 $originalValues = $fields->getOriginalValues();
114 if (array_key_exists("NAME", $originalValues))
115 $logFields['OLD_NAME'] = $originalValues["NAME"];
116
117 if (array_key_exists("VALUE", $originalValues))
118 $logFields['OLD_VALUE'] = $originalValues["VALUE"];
119
120 if (array_key_exists("CODE", $originalValues))
121 $logFields['OLD_CODE'] = $originalValues["CODE"];
122
123 return $logFields;
124 }
125
129 private function getLogFieldsForAdd()
130 {
131 $logFields = [
132 "NAME" => $this->getField("NAME"),
133 "VALUE" => $this->getField("VALUE"),
134 "CODE" => $this->getField("CODE"),
135 ];
136
137 return $logFields;
138 }
139
146 private function addToLog($type, $fields)
147 {
149 $propertyCollection = $this->getCollection();
150
152 if (!$order = $propertyCollection->getOrder())
153 {
154 throw new Main\ObjectNotFoundException('Entity "Order" not found');
155 }
156
157 $registry = Registry::getInstance(static::getRegistryType());
158
160 $orderHistory = $registry->getOrderHistoryClassName();
161 $orderHistory::addLog(
162 'PROPERTY',
163 $order->getId(),
164 $type,
165 $this->getId(),
166 $this,
167 $fields,
168 $orderHistory::SALE_ORDER_HISTORY_LOG_LEVEL_1
169 );
170 }
171
180 protected function add()
181 {
183 $propertyCollection = $this->getCollection();
184
186 if (!$order = $propertyCollection->getOrder())
187 {
188 throw new Main\ObjectNotFoundException('Entity "Order" not found');
189 }
190
191 $logFields = [];
192 if ($order->getId() > 0)
193 {
194 $logFields = $this->getLogFieldsForAdd();
195 }
196
197 $result = parent::add();
198 if ($result->isSuccess())
199 {
200 if ($order->getId() > 0)
201 {
202 $this->addToLog('PROPERTY_ADD', $logFields);
203 }
204 }
205
206 return $result;
207 }
208}
static add(array $data)
Definition entity.php:150
static extractDeliveryIdList(Entity $order)
static extractPaySystemIdList(Entity $order)
static extractTradingPlatformIdList(Entity $order)
static extractTpLandingIdList(Entity $order)
static getInstance($type)
Definition registry.php:183