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

			continue;
		}

		/** @var SyncEntitiesSyncSection $savedSyncSection */
		if ($savedSyncSection = $this->syncSectionMap->has(
			$externalSyncSection->getSectionConnection()->getVendorSectionId()
		))
		{
			$savedSyncSection = $this->syncSectionMap->getItem(
				$externalSyncSection->getSectionConnection()->getVendorSectionId()
			);
			$externalSyncSection
				->getSectionConnection()
					->setId($savedSyncSection->getSectionConnection()->getId())
					->setSyncToken($savedSyncSection->getSectionConnection()->getSyncToken())
					->setPageToken($savedSyncSection->getSectionConnection()->getPageToken())
			;

			$savedSection = $savedSyncSection->getSection();
			$externalSyncSection
				->getSection()
					->setId($savedSection->getId())
					->setXmlId($savedSection->getXmlId())
					->setCreator($savedSection->getCreator())
					->setExternalType($savedSection->getExternalType())
					->setIsActive($savedSection->isActive())
					->setType($savedSection->getType())
			;
			if (empty($externalSyncSection->getSection()->getColor()))
			{
				$externalSyncSection->getSection()->setColor(
					$savedSection->getColor()
						?: CorePropertyColorHelper::getOurColorRandom()
				);
			}
			if ($savedSection->isLocal())
			{
				$externalSyncSection->getSection()->setName($savedSection->getName());
			}
		}
	}
}