• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/update/googletonewsync.php
  • Класс: BitrixCalendarUpdateGoogleToNewSync
  • Вызов: GoogleToNewSync::execute
public function execute(array &$option): bool
{
	if (!Loader::includeModule(self::$moduleId) || !Loader::includeModule('dav'))
	{
		return self::FINISH_EXECUTION;
	}
	if (Option::get(self::$moduleId, self::OPTION_CONVERTED, 'N') === 'Y')
	{
		CCalendar::ClearCache();

		return self::FINISH_EXECUTION;
	}

	$status = $this->loadCurrentStatus();
	$events = $this->getGoogleEvents();
	$eventIds = [];
	if ($events->count())
	{
		foreach ($events as $event)
		{
			$status['lastEventId'] = $event->getId();
			/** @var EO_SectionConnection $connection */
			$connection = $event->get('SECTION_CONNECTION');
			if ($connection && $connectionId = $connection->getConnectionId())
			{
				$eventIds[] = $this->createEventConnection($event, $connectionId);
			}
			else
			{
				$eventIds[] = $event->getId();
			}
		}

		if ($eventIds)
		{
			$this->cleanExtraEventInfo($eventIds);
			$status['steps'] += $events->count();
		}

			Option::set(self::$moduleId, self::OPTION_STATUS, serialize($status));
			$option = [
				'count' => $status['count'],
				'steps' => $status['steps'],
				'lastEventId' => $status['lastEventId'],
			];

			return self::CONTINUE_EXECUTION;
	}

	$this->deDuplicate();

	Option::set(self::$moduleId, self::OPTION_CONVERTED, 'Y');
	Option::delete(self::$moduleId, ['name' => self::OPTION_STATUS]);
	$this->unblockAllPushChannels();
	CCalendar::ClearCache();

	return self::FINISH_EXECUTION;
}