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

		if (in_array($syncSection->getSection()->getId(), $syncSectionKeyIdList, true))
		{
			$syncSectionMap->remove($key);
		}
		else
		{
			$syncSectionKeyIdList[$syncSection->getSectionConnection()->getVendorSectionId()] = $syncSection->getSection()->getId();
		}

		$this->sectionConnectionMapper->delete($syncSection->getSectionConnection(), ['softDelete' => false]);
		$this->syncSectionMap->remove($key);
		$syncSection->setSectionConnection(null);
	}

	// todo optimize this process after update mappers
	if ($syncSectionKeyIdList)
	{
		$syncEventMap = $this->syncEventFactory->getSyncEventMapBySyncSectionIdCollectionForExport(
			$syncSectionKeyIdList,
			$this->factory->getConnection()->getOwner()->getId(),
			$this->factory->getConnection()->getId()
		);
		if ($syncEventMap->count())
		{
			/** @var SyncEntitiesSyncEvent $syncEvent */
			foreach ($syncEventMap as $syncEvent)
			{
				if ($syncEvent->getEventConnection() === null)
				{
					continue;
				}

				$this->eventConnectionMapper->delete($syncEvent->getEventConnection(), ['softDelete' => false]);
			}
		}
	}

	return $syncSectionMap;
}