Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
servicelist.php
1<?php
2
3namespace Bitrix\Pull\Push;
4
6{
7 const TYPE_APPLE = 'APPLE';
8 const TYPE_APPLE_VOIP = 'APPLE/VOIP';
9 const TYPE_GOOGLE = 'GOOGLE';
10 const TYPE_GOOGLE_REV2 = 'GOOGLE/REV2';
11 const TYPE_HUAWEI = 'HUAWEI';
12
13 public static function getServiceList(): array
14 {
15 $result = [
16 static::TYPE_APPLE => [
17 'ID' => static::TYPE_APPLE,
18 'CLASS' => Service\Apple::class,
19 'NAME' => 'Apple Push Notifications'
20 ],
21 static::TYPE_APPLE_VOIP => [
22 'ID' => static::TYPE_APPLE_VOIP,
23 'CLASS' => Service\AppleVoip::class,
24 'NAME' => 'Apple Push Notifications (Voip Service)'
25 ],
26 static::TYPE_GOOGLE_REV2 => [
27 'ID' => static::TYPE_GOOGLE_REV2,
28 'CLASS' => Service\GoogleInteractive::class,
29 'NAME' => 'Google Cloud Messages rev.2'
30 ],
31 static::TYPE_GOOGLE => [
32 'ID' => static::TYPE_GOOGLE,
33 'CLASS' => Service\Google::class,
34 'NAME' => 'Google Cloud Messages'
35 ],
36 static::TYPE_HUAWEI => [
37 'ID' => static::TYPE_HUAWEI,
38 'CLASS' => Service\HuaweiPushKit::class,
39 'NAME' => 'Huawei Cloud Messages'
40 ]
41 ];
42
43 foreach (GetModuleEvents("pull", "OnPushServicesBuildList", true) as $arEvent)
44 {
45 $res = ExecuteModuleEventEx($arEvent);
46 if (is_array($res))
47 {
48 if (!is_array($res[0]))
49 {
50 $res = [$res];
51 }
52 foreach ($res as $serv)
53 {
54 if (!class_exists($serv['CLASS']))
55 {
56 trigger_error('Class ' . $serv['CLASS'] . ' does not exists', E_USER_WARNING);
57 continue;
58 }
59 if (!($serv['CLASS'] instanceof PushService))
60 {
61 trigger_error('Class ' . $serv['CLASS'] . ' must implement ' . PushService::class .' interface', E_USER_WARNING);
62 continue;
63 }
64
65 $result[$serv["ID"]] = $serv;
66 }
67 }
68 }
69
70
71 return $result;
72 }
73}