Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
IblockElementXmlProvider.php
1<?php
2
4
8
10{
11 protected const ENTITY_ID = 'iblock-element-xml';
12
13 public function doSearch(SearchQuery $searchQuery, Dialog $dialog): void
14 {
15 $filter = [];
16
17 $query = $searchQuery->getQuery();
18 if ($query !== '')
19 {
20 $filter = $this->getQueryFilter($query);
21 }
22
23 $elements = $this->getElements($filter);
24 foreach ($elements as $element)
25 {
26 $dialog->addItem(
27 $this->makeItem($element)
28 );
29 }
30 }
31
32 private function getQueryFilter(string $query): array
33 {
34 return [
35 [
36 'LOGIC' => 'OR',
37 '%XML_ID' => $query,
38 '*SEARCHABLE_CONTENT' => $query,
39 ],
40 ];
41 }
42
43 protected function makeItem(array $element, string $propertyType = ''): Item
44 {
45 $itemParams = [
46 'id' => $element['ID'] ?? null,
47 'entityId' => self::ENTITY_ID,
48 'title' => $element['NAME'] ?? null,
49 'subtitle' => $element['XML_ID'] ?? null,
50 'description' => $element['DETAIL_TEXT'] ?? null,
51 'avatar' => $element['PREVIEW_PICTURE'] ?? null,
52 'customData' => [
53 'xmlId' => $element['XML_ID'] ?? null,
54 ],
55 ];
56
57 return new Item($itemParams);
58 }
59}