Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
regionsprovider.php
1<?php
2
4
10
12{
13 const SEARCH_TYPE = 'adgeolocation';
14 const ENTITY_TYPE = 'regions';
15
16 public function doSearch(SearchQuery $searchQuery, Dialog $dialog): void
17 {
18 $service = Configurator::getService();
19 $service->setClientId($this->getOption('clientId'));
20 $searchQuery->setCacheable(false);
21
22 $response = Configurator::searchTargetingData(
23 AdCampaignFacebook::TYPE_CODE,
24 [
25 'q' => $searchQuery->getQuery(),
26 'type' => static::SEARCH_TYPE
27 ]
28 );
29
30 $items = [];
31
32 foreach ($response as $value)
33 {
34 if (!isset($value['key']))
35 {
36 continue;
37 }
38
39 $items[] =
40 new Item(
41 [
42 'id' => $value['key'],
43 'entityId' => static::ENTITY_TYPE,
44 'title' => $value['name'],
45 'tagOptions' => [
46 'bgColor' => "#{$this->stringToColor($value['key'])}",
47 'textColor' => "#fff"
48 ],
49 'customData' => [
50 'type' => $value['type'],
51 ]
52 ]
53 );
54 }
55
56 $dialog->addItems(
57 $items
58 );
59 }
60}
doSearch(SearchQuery $searchQuery, Dialog $dialog)
getOption(string $option, $defaultValue=null)