Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
PropertyValue.php
1<?php
2
4
6
16{
17 // ToDo property cast map (int)1 => '1'
18 public function setValue($value): self
19 {
21 $property = $this->getParent();
22
23 if ($property->getPropertyType() === 'S' && $property->getUserType() === 'HTML')
24 {
25 $value = $this->prepareValueForHtmlProperty($value);
26 }
27
28 return $this->setField('VALUE', $value);
29 }
30
31 // ToDo do we need to create HtmlProperty entity (descendant of PropertyValue)?
32 protected function prepareValueForHtmlProperty($value)
33 {
34 if (!is_array($value) || !isset($value['TYPE']))
35 {
36 $oldValue = $this->getField('VALUE');
37 $value = [
38 'TEXT' => $value,
39 'TYPE' => $oldValue['TYPE'] ?? 'HTML',
40 ];
41 }
42
43 return $value;
44 }
45
46 public function getValue()
47 {
48 return $this->getField('VALUE');
49 }
50
51 public function setDescription($description): self
52 {
53 return $this->setField('DESCRIPTION', $description);
54 }
55
56 public function getDescription()
57 {
58 return $this->getField('DESCRIPTION');
59 }
60}
setField(string $name, $value)