Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
builder.php
1<?php
2
4
6
12{
14 private $entity;
15
17 private $content;
18
20 private $fieldName;
21
28 public function __construct(Entity\Base $entity, $fieldName)
29 {
30 $this->entity = $entity;
31 $this->fieldName = $fieldName;
32 }
33
39 public function isFullTextIndexEnabled()
40 {
41 return $this->entity->fullTextIndexEnabled($this->fieldName);
42 }
43
49 public function hasField()
50 {
51 return $this->entity->hasField($this->fieldName);
52 }
53
59 public function getContent()
60 {
61 if (!$this->content)
62 {
63 $this->content = new Content;
64 }
65
66 return $this->content;
67 }
68
74 public function isEnabled()
75 {
76 return $this->hasField() && $this->isFullTextIndexEnabled();
77 }
78
85 public function save($entityId)
86 {
87 $dataClass = $this->entity->getDataClass();
88 return $dataClass::update(
89 $entityId,
90 array($this->fieldName => $this->content->getString())
91 )->isSuccess();
92 }
93
101 public function applyFilter(array &$filter, $searchString)
102 {
103 if (!$searchString)
104 {
105 return false;
106 }
107 if (!$this->hasField())
108 {
109 return false;
110 }
111
112 $isFullTextEnabled = $this->isFullTextIndexEnabled();
113 $operation = $isFullTextEnabled ? '*' : '*%';
114 $filter["{$operation}{$this->fieldName}"] = Content::encodeText($searchString);
115
116 return true;
117 }
118}
__construct(Entity\Base $entity, $fieldName)
Definition builder.php:28
applyFilter(array &$filter, $searchString)
Definition builder.php:101