Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
elementv1.php
1<?php
9namespace Bitrix\Iblock\ORM;
10
15
20abstract class ElementV1 extends CommonElement
21{
32 public function sysSetValue($fieldName, $value)
33 {
34 $field = $this->entity->getField($fieldName);
35
36 if ($field instanceof PropertyReference)
37 {
38 // for v1 preferable to change existing object (sel+upd) instead of new (del+ins)
39 if ($this->state !== State::RAW && !$this->sysIsFilled($fieldName))
40 {
41 $this->fill($fieldName);
42 }
43 }
44
45 return parent::sysSetValue($fieldName, $value);
46 }
47
48 public function sysSaveRelations(Result $result)
49 {
50 parent::sysSaveRelations($result);
51
52 // save single value references
53 foreach ($this->entity->getFields() as $field)
54 {
55 if ($field instanceof PropertyReference)
56 {
57 if ($this->sysHasValue($field->getName()) && !empty($this->get($field->getName())))
58 {
60 $valueObject = $this->get($field->getName());
61
62 if ($valueObject->state == State::RAW)
63 {
64 // previously we made fill, so now we don't need to remove old value
65 // it would be insert only, and that's all
66 $valueObject->save();
67 }
68 elseif ($valueObject->state == State::CHANGED)
69 {
70 // regular update
71 $valueObject->save();
72 }
73 }
74 }
75 }
76 }
77}
sysSetValue($fieldName, $value)
Definition elementv1.php:32