Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
MorePhotoImage.php
1<?php
2
4
7
17{
18 public const CODE = 'MORE_PHOTO';
19
20 public function setFileStructure(array $fileFields): BaseImage
21 {
22 parent::setFileStructure($fileFields);
23
25 if ($parent = $this->getParent())
26 {
27 $property = $parent->getPropertyCollection()->findByCode(self::CODE);
28 if ($property)
29 {
31 $item = $property->getPropertyValueCollection()->findByValue($this->getId());
32
33 if ($item)
34 {
35 $item->setValue($this->getFileStructure());
36 }
37 else
38 {
39 if ($property->isMultiple())
40 {
41 $values = $property->getPropertyValueCollection()->getValues();
42 $values[] = $this->getFileStructure();
43 }
44 else
45 {
46 $values = [
47 $this->getFileStructure(),
48 ];
49 }
50 $property->getPropertyValueCollection()->setValues($values);
51 }
52 }
53 }
54
55 return $this;
56 }
57
58 public function remove(): BaseEntity
59 {
61 if ($parent = $this->getParent())
62 {
63 $property = $parent->getPropertyCollection()->findByCode(MorePhotoImage::CODE);
64 if ($property)
65 {
66 $valueCollection = $property->getPropertyValueCollection();
67
68 foreach ($valueCollection as $item)
69 {
70 if ((int)$item->getValue() === $this->getId())
71 {
72 $valueCollection->remove($item);
73 break;
74 }
75 }
76 }
77 }
78
79 return parent::remove();
80 }
81}
setFileStructure(array $fileFields)
Definition BaseImage.php:35