1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
sectionmanager.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Sync\Icloud;
4
5use Bitrix\Calendar\Core\Section\Section;
6use Bitrix\Calendar\Sync\Connection\Connection;
7use Bitrix\Calendar\Sync\Connection\SectionConnection;
8use Bitrix\Calendar\Sync\Connection\Server;
9use Bitrix\Calendar\Core;
10use Bitrix\Calendar\Sync\Managers\SectionManagerInterface;
11use Bitrix\Calendar\Sync\Push\Push;
12use Bitrix\Calendar\Sync\Util\Result;
13use Bitrix\Calendar\Sync\Util\SectionContext;
14use Bitrix\Main\Error;
15use Bitrix\Main\LoaderException;
16
18{
27 public function create(Section $section, SectionContext $context): Result
28 {
29 $result = new Result();
30 $path = $this->connection->getServer()->getBasePath() . VendorSyncService::generateUuid();
31 $data = $this->getApiService()->createSection($path, $section);
32
33 if ($this->getApiService()->getError())
34 {
35 $this->processConnectionError($this->connection, $this->getApiService()->getError());
36 }
37
38 if ($data)
39 {
40 $result->setData([
41 'id' => $data['XML_ID'],
42 'version' => $data['MODIFICATION_LABEL']
43 ]);
44 }
45 else
46 {
47 $result->addError(new Error('Error while trying to save section'));
48 }
49
50 return $result;
51 }
52
61 public function update(Section $section, SectionContext $context): Result
62 {
63 $result = new Result();
64 $data = $this->getApiService()->updateSection($context->getSectionConnection()->getVendorSectionId(), $section);
65
66 if ($this->getApiService()->getError())
67 {
68 $this->processConnectionError($this->connection, $this->getApiService()->getError());
69 }
70
71 if ($data['XML_ID'])
72 {
73 $result->setData([
74 'id' => $data['XML_ID'],
75 'version' => $data['MODIFICATION_LABEL']
76 ]);
77 }
78 else
79 {
80 if ($data['ERROR'])
81 {
82 $result->setData([
83 'error' => $data['ERROR']
84 ]);
85 }
86
87 $result->addError(new Error('Error while trying to update section'));
88 }
89
90 return $result;
91 }
92
101 public function delete(Section $section, SectionContext $context): Result
102 {
103 $result = new Result();
104 $data = $this->getApiService()->deleteSection($context->getSectionConnection()->getVendorSectionId());
105
106 if ($this->getApiService()->getError())
107 {
108 $this->processConnectionError($this->connection, $this->getApiService()->getError());
109 }
110
111 if (!$data)
112 {
113 $result->addError(new Error('Error while trying to delete section'));
114 }
115
116 return $result;
117 }
118
122 private function getApiService(): ApiService
123 {
124 if (!$this->apiService)
125 {
126 $this->apiService = new ApiService();
127 }
128
129 return $this->apiService;
130 }
131
137 public function subscribe(SectionConnection $link): Result
138 {
139 return new Result();
140 }
141
147 public function resubscribe(Push $push): Result
148 {
149 return new Result();
150 }
151
159 {
160 $result = [];
161 $server = $this->prepareServerData($connection->getServer());
162 $data = $this->getApiService($server)->getSectionsList($connection->getServer()->getBasePath());
163 if ($data && is_array($data))
164 {
165 foreach ($data as $section)
166 {
167 if ($section['supported-calendar-component-set'] === 'VEVENT')
168 {
169 $result[] = [
170 'XML_ID' => $section['href'],
171 'NAME' => $section['displayname'],
172 'DESCRIPTION' => $section['calendar-description'],
173 'TYPE' => $section['supported-calendar-component-set'],
174 'COLOR' => $section['calendar-color'],
175 'MODIFICATION_LABEL' => $section['getctag'],
176 ];
177 }
178 }
179 }
180
181 return $result;
182 }
183
185 {
186 return [Helper::ACCOUNT_TYPE];
187 }
188
195 private function processConnectionError(Connection $connection, array $error): void
196 {
197 $parsedError = '[' . $error[0] . '] ' . $error[1];
198 \CDavConnection::SetLastResult($connection->getId(), $parsedError);
199 }
200}
$path
Определения access_edit.php:21
$connection
Определения actionsdefinitions.php:38
prepareServerData(Server $server)
Определения abstractmanager.php:53
getSections(Connection $connection)
Определения sectionmanager.php:158
create(Section $section, SectionContext $context)
Определения sectionmanager.php:27
subscribe(SectionConnection $link)
Определения sectionmanager.php:137
update(Section $section, SectionContext $context)
Определения sectionmanager.php:61
Определения error.php:15
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$context
Определения csv_new_setup.php:223
$error
Определения subscription_card_product.php:20