Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
webhook.php
1<?php
2
4
7use CRestUtil;
8
14{
15 private const CACHE_TIME = 86400;
16 private const CACHE_DIR = '/rest/integration/data/webhook/';
17
21 public static function getList() : array
22 {
23 $result = [];
24
25 $cache = Cache::createInstance();
26 if ($cache->initCache(static::CACHE_TIME, 'all' . LANGUAGE_ID, static::CACHE_DIR))
27 {
28 $result = $cache->getVars();
29 }
30 elseif ($cache->startDataCache())
31 {
32 $eventDictionary = new Dictionary\WebHook();
33 $eventDictionaryResult = [];
34 foreach ($eventDictionary as $event)
35 {
36 $eventDictionaryResult[mb_strtoupper($event['code'])] = $event;
37 }
38 $eventList = CRestUtil::getEventList();
39 $eventDistinctId = [];
40 foreach ($eventList as $type => $events)
41 {
42 foreach ($events as $event)
43 {
44 if (array_key_exists($event, $eventDictionaryResult) && !in_array(mb_strtoupper($event), $eventDistinctId))
45 {
46 $event = mb_strtoupper($event);
47 $eventDistinctId[] = $event;
48
49 $result[] = [
50 'id' => $event,
51 'name' => !empty($eventDictionaryResult[$event]['name'])
52 ? $eventDictionaryResult[$event]['name'] . ' (' . $event . ')' : $event,
53 'descr' => !empty($eventDictionaryResult[$event]['descr'])
54 ? $eventDictionaryResult[$event]['descr'] : '',
55 ];
56 }
57 }
58 }
59 $cache->endDataCache($result);
60 }
61
62 return $result;
63 }
64}