Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
apiclient.php
1<?php
2
4
6
8{
10 protected Helper $helper;
12 protected \CDavGroupdavClientCalendar $davClient;
14 protected ?RequestLogger $logger = null;
16 protected ?int $userId = null;
17
24 public function __construct(\CDavGroupdavClientCalendar $davClient, int $userId = null)
25 {
26 $this->helper = new Helper();
27 $this->davClient = $davClient;
28 $this->userId = $userId;
29
30 if ($this->userId && RequestLogger::isEnabled())
31 {
32 $this->logger = new RequestLogger($this->userId, $this->helper::ACCOUNT_TYPE);
33 }
34 }
35
44 public function propfind(
45 string $url,
46 array $properties = null,
47 array $filter = null,
48 int $depth = 1
49 ): ?\CDavXmlDocument
50 {
51 $this->davClient->Connect();
52 $result = $this->davClient->Propfind(
53 $url,
54 $properties,
55 $filter,
56 $depth,
57 $this->logger
58 );
59 $this->davClient->Disconnect();
60
61 if (!$result || $this->davClient->getError())
62 {
63 return null;
64 }
65
66 return $result->GetBodyXml();
67 }
68
75 public function proppatch(string $url, string $data)
76 {
77 $this->davClient->Connect();
78 $data = $this->davClient->Decode($data);
79 $result = $this->davClient->Proppatch($url, $data, $this->logger);
80 $this->davClient->Disconnect();
81
82 if (!$result)
83 {
84 return null;
85 }
86
87 return $result->GetStatus();
88 }
89
96 public function mkcol(string $url, string $data)
97 {
98 $this->davClient->Connect();
99 $data = $this->davClient->Decode($data);
100 $result = $this->davClient->Mkcol($url, $data, $this->logger);
101 $this->davClient->Disconnect();
102
103 if (!$result)
104 {
105 return null;
106 }
107
108 return $result->GetStatus();
109 }
110
116 public function delete(string $url)
117 {
118 $this->davClient->Connect();
119 $result = $this->davClient->Delete($url, $this->logger);
120 $this->davClient->Disconnect();
121
122 if (!$result)
123 {
124 return null;
125 }
126
127 return $result->GetStatus();
128 }
129
136 public function put(string $url, string $data)
137 {
138 $this->davClient->Connect();
139 $data = $this->davClient->Decode($data);
140 $result = $this->davClient->Put($url, $data, $this->logger);
141 $this->davClient->Disconnect();
142
143 if (!$result)
144 {
145 return null;
146 }
147
148 return $result->GetStatus();
149 }
150}
__construct(\CDavGroupdavClientCalendar $davClient, int $userId=null)
Definition apiclient.php:24
mkcol(string $url, string $data)
Definition apiclient.php:96
CDavGroupdavClientCalendar $davClient
Definition apiclient.php:12
put(string $url, string $data)
propfind(string $url, array $properties=null, array $filter=null, int $depth=1)
Definition apiclient.php:44
proppatch(string $url, string $data)
Definition apiclient.php:75