• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/sync/managers/vendordataexchangemanager.php
  • Класс: BitrixCalendarSyncManagersVendorDataExchangeManager
  • Вызов: VendorDataExchangeManager::handleSectionsToLocalStorage
private function handleSectionsToLocalStorage(SyncEntitiesSyncSectionMap $syncSectionMap): void
{
	/** @var SyncEntitiesSyncSection $syncSection */
	foreach ($syncSectionMap as $key => $syncSection)
	{
		if (!$this->validateSyncSectionBeforeSave($syncSection))
		{
			$this->updateFailedSyncSection($syncSection);

			continue;
		}

		if ($syncSection->getAction() === SyncDictionary::SYNC_STATUS['delete'])
		{
			if ($syncSection->getSection()->isLocal())
			{
				$this->createLocalDeletedSection($syncSection);
			}
			else
			{
				$this->deleteSyncSectionFromLocalStorage($syncSection);
				continue;
			}
		}

		if ($syncSection->getSection()->isNew())
		{
			/** @var CoreSectionSection $section */
			// TODO: change later to saveManager
			$this->sectionMapper->create($syncSection->getSection());
			$this->savePermissions($syncSection);

			$this->sectionConnectionMapper->create(
				$syncSection->getSectionConnection()->setSection($syncSection->getSection())
			);
		}
		else
		{
			$this->sectionMapper->update($syncSection->getSection());
			$sectionConnection = $syncSection->getSectionConnection();
			$sectionConnection->setSection($syncSection->getSection());

			$sectionConnection->isNew()
				? $this->sectionConnectionMapper->create($sectionConnection)
				: $this->sectionConnectionMapper->update($sectionConnection)
			;
		}

		$syncSection->setAction(SyncDictionary::SYNC_SECTION_ACTION['success']);

		$this->syncSectionMap->add($syncSection, $key);
	}
}