1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
propertyvaluecollectionbase.php
См. документацию.
1<?php
2
3namespace Bitrix\Sale;
4
5use Bitrix\Main;
6use Bitrix\Sale\Internals\CollectableEntity;
7use Bitrix\Main\ArgumentOutOfRangeException;
8use Bitrix\Main\Localization\Loc;
9
10Loc::loadMessages(__FILE__);
11
17{
19 protected $order;
20
25 protected static function getOnValueDeletedEventName(): string
26 {
27 return 'OnSalePropertyValueDeleted';
28 }
29
34 protected static function getOnBeforeValueDeletedEventName(): string
35 {
36 return 'OnBeforeSalePropertyValueDeleted';
37 }
38
42 protected static function getPropertyClassName(): string
43 {
44 $registry = Registry::getInstance(static::getRegistryType());
45 return $registry->getPropertyClassName();
46 }
47
52 public static function load(OrderBase $order)
53 {
55 $propertyCollection = static::createPropertyValueCollectionObject();
56 $propertyCollection->setOrder($order);
57
58 $registry = Registry::getInstance(static::getRegistryType());
60 $propertyValueClassName = $registry->getPropertyValueClassName();
61
62 $props = $propertyValueClassName::loadForOrder($order);
63
65 foreach ($props as $prop)
66 {
67 $prop->setCollection($propertyCollection);
68 $propertyCollection->bindItem($prop);
69 }
70
71 return $propertyCollection;
72 }
73
77 protected function getEntityParent()
78 {
79 return $this->getOrder();
80 }
81
86 public function addItem(CollectableEntity $property)
87 {
89 $property = parent::addItem($property);
90
91 $order = $this->getOrder();
92 return $order->onPropertyValueCollectionModify(EventActions::ADD, $property);
93 }
94
102 public function deleteItem($index)
103 {
104 $oldItem = parent::deleteItem($index);
105 $order = $this->getOrder();
107 }
108
117 public function onItemModify(CollectableEntity $item, $name = null, $oldValue = null, $value = null)
118 {
119 if (!$item instanceof EntityPropertyValue)
120 throw new Main\NotSupportedException();
121
123 $order = $this->getOrder();
124 return $order->onPropertyValueCollectionModify(EventActions::UPDATE, $item, $name, $oldValue, $value);
125 }
126
134 public function onOrderModify($name, $oldValue, $value)
135 {
136 return new Result();
137 }
138
142 public function getOrder()
143 {
144 return $this->order;
145 }
146
150 public function setOrder(OrderBase $order)
151 {
152 $this->order = $order;
153 }
154
159 protected static function getPropertyValueClassName(): string
160 {
161 $registry = Registry::getInstance(static::getRegistryType());
162 return $registry->getPropertyValueClassName();
163 }
164
169 protected static function createPropertyValueCollectionObject()
170 {
171 $registry = Registry::getInstance(static::getRegistryType());
172 $propertyValueCollectionClassName = $registry->getPropertyValueCollectionClassName();
173 return new $propertyValueCollectionClassName();
174 }
175
186 public function getGroupProperties($groupId)
187 {
188 return $this->getPropertiesByGroupId($groupId);
189 }
190}
const ADD
Определения eventactions.php:8
const DELETE
Определения eventactions.php:10
const UPDATE
Определения eventactions.php:9
onPropertyValueCollectionModify($action, EntityPropertyValue $property, $name=null, $oldValue=null, $value=null)
Определения orderbase.php:625
onOrderModify($name, $oldValue, $value)
static getInstance($type)
Определения registry.php:183
$name
Определения menu_edit.php:35
$order
Определения payment.php:8
$props
Определения template.php:269