• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/sync/handlers/synceventmergehandler.php
  • Класс: BitrixCalendarSyncHandlersSyncEventMergeHandler
  • Вызов: SyncEventMergeHandler::mergeRemindCollections
private function mergeRemindCollections(
	CoreEventPropertiesRemindCollection $externalRemindCollection,
	CoreEventPropertiesRemindCollection $localRemindCollection
): CoreEventPropertiesRemindCollection
{
	$prepareMap = function (?CoreEventPropertiesRemindCollection $collection)
	{
		$result = [];
		/** @var CoreEventPropertiesRemind $item */
		foreach ($collection as $index => $item)
		{
			$result[$item->getTimeBeforeStartInMinutes()] = $index;
		}
		return $result;
	};

	$externalMap = $prepareMap($externalRemindCollection);
	$localMap = $prepareMap($localRemindCollection);

	foreach ($localMap as $key => $index)
	{
		if (!array_key_exists($key, $externalMap))
		{
			$localRemindCollection->remove($index);
		}
	}

	return $localRemindCollection->addItems($externalRemindCollection->getCollection());
}