Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
vendorsyncservice.php
1<?php
2
4
6{
8 protected Helper $helper;
10 protected ?ApiService $apiService = null;
12 protected ?string $error = null;
13
14 public function __construct()
15 {
16 $this->helper = new Helper();
17 }
18
19 //DavConnection data or only authorization data
20 public function getCalendarServerPath(array $connection): ?string
21 {
22 if (empty($connection['ID']))
23 {
24 $server = $this->getApiService()->prepareUrl($this->helper::SERVER_PATH);
25
26 $server['path'] = $this->getApiService()->getPrinciples($connection, $server);
27 if (!$server['path'])
28 {
29 return null;
30 }
31
32 $calendarPath = $this->getApiService()->getCalendarPath($connection, $server);
33
34 if ($calendarPath)
35 {
36 return $calendarPath;
37 }
38
39 return null;
40 }
41
42 return $connection['SERVER_SCHEME']
43 . '://'
44 . $connection['SERVER_HOST']
45 . $connection['SERVER_PATH']
46 ;
47 }
48
49 public static function generateUuid(): string
50 {
51 $word = sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
52 mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
53 mt_rand( 0, 0xffff ),
54 mt_rand( 0, 0x0fff ) | 0x4000,
55 mt_rand( 0, 0x3fff ) | 0x8000,
56 mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
57 );
58
59 return mb_strtoupper($word);
60 }
61
62 private function getApiService(): ApiService
63 {
64 if (!$this->apiService)
65 {
66 $this->apiService = new ApiService();
67 }
68
69 return $this->apiService;
70 }
71
72 public function getError(): ?string
73 {
74 return $this->error;
75 }
76}