- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/lib/sync/icloud/vendorsyncmanager.php
- Класс: BitrixCalendarSyncIcloudVendorSyncManager
- Вызов: VendorSyncManager::syncIcloudConnection
public function syncIcloudConnection(int $connectionId): array
{
$userId = CCalendar::GetUserId();
$connection = $this->mapperFactory->getConnection()->getById($connectionId);
if (!$connection)
{
return [
'status' => self::STATUS_ERROR,
'message' => 'Connection not found',
];
}
if ($connection->getOwner()->getId() !== $userId)
{
return [
'status' => self::STATUS_ERROR,
'message' => 'Access Denied',
];
}
$result = ManagersDataSyncManager::createInstance()->dataSync($userId);
if (!$result)
{
return [
'status' => self::STATUS_ERROR,
'message' => 'Error while trying to import events',
];
}
Util::addPullEvent(
'process_sync_connection',
$userId,
[
'vendorName' => $this->helper::ACCOUNT_TYPE,
'stage' => 'import_finished',
'accountName' => $connection->getServer()->getUserName(),
]
);
$result = (new ManagersOutgoingManager($connection))->export();
if (!$result->isSuccess())
{
return [
'status' => self::STATUS_ERROR,
'message' => 'Error while trying to export events',
];
}
Util::addPullEvent(
'process_sync_connection',
$userId,
[
'vendorName' => $this->helper::ACCOUNT_TYPE,
'stage' => 'export_finished',
'accountName' => $connection->getServer()->getUserName(),
]
);
NotificationManager::addFinishedSyncNotificationAgent(
$userId,
$this->helper::ACCOUNT_TYPE
);
return [
'status' => self::STATUS_SUCCESS
];
}