Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
propertyvaluecollectionbase.php
1<?php
2
3namespace Bitrix\Sale;
4
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
54 public static function load(OrderBase $order)
55 {
57 $propertyCollection = static::createPropertyValueCollectionObject();
58 $propertyCollection->setOrder($order);
59
60 $registry = Registry::getInstance(static::getRegistryType());
62 $propertyValueClassName = $registry->getPropertyValueClassName();
63
64 $props = $propertyValueClassName::loadForOrder($order);
65
67 foreach ($props as $prop)
68 {
69 $prop->setCollection($propertyCollection);
70 $propertyCollection->addItem($prop);
71 }
72
73 return $propertyCollection;
74 }
75
79 protected function getEntityParent()
80 {
81 return $this->getOrder();
82 }
83
89 public function addItem(CollectableEntity $property)
90 {
92 $property = parent::addItem($property);
93
94 $order = $this->getOrder();
95 return $order->onPropertyValueCollectionModify(EventActions::ADD, $property);
96 }
97
105 public function deleteItem($index)
106 {
107 $oldItem = parent::deleteItem($index);
108 $order = $this->getOrder();
110 }
111
120 public function onItemModify(CollectableEntity $item, $name = null, $oldValue = null, $value = null)
121 {
122 if (!$item instanceof EntityPropertyValue)
123 throw new Main\NotSupportedException();
124
126 $order = $this->getOrder();
127 return $order->onPropertyValueCollectionModify(EventActions::UPDATE, $item, $name, $oldValue, $value);
128 }
129
137 public function onOrderModify($name, $oldValue, $value)
138 {
139 return new Result();
140 }
141
145 public function getOrder()
146 {
147 return $this->order;
148 }
149
153 public function setOrder(OrderBase $order)
154 {
155 $this->order = $order;
156 }
157
162 protected static function getPropertyValueClassName(): string
163 {
164 $registry = Registry::getInstance(static::getRegistryType());
165 return $registry->getPropertyValueClassName();
166 }
167
172 protected static function createPropertyValueCollectionObject()
173 {
174 $registry = Registry::getInstance(static::getRegistryType());
175 $propertyValueCollectionClassName = $registry->getPropertyValueCollectionClassName();
176 return new $propertyValueCollectionClassName();
177 }
178
189 public function getGroupProperties($groupId)
190 {
191 return $this->getPropertiesByGroupId($groupId);
192 }
193}
static loadMessages($file)
Definition loc.php:64
onItemModify(CollectableEntity $item, $name=null, $oldValue=null, $value=null)
onPropertyValueCollectionModify($action, EntityPropertyValue $property, $name=null, $oldValue=null, $value=null)
static getInstance($type)
Definition registry.php:183