• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/sync/managers/pushwatchingmanager.php
  • Класс: BitrixCalendarSyncManagersPushWatchingManager
  • Вызов: PushWatchingManager::recreateSectionPushChannel
private function recreateSectionPushChannel(
	PushManagerInterface $vendorPushManager,
	Push $pushChannel,
	SectionConnection $sectionLink
): Result
{
	$result = new Result();
	try
	{
		$vendorPushManager->deletePush($pushChannel);
		$result = $vendorPushManager->addSectionPush($sectionLink);
		if ($result->isSuccess() && !empty($result->getData()))
		{
			$data = $result->getData();
			$pushChannel
				->setChannelId($data['CHANNEL_ID'])
				->setResourceId($data['RESOURCE_ID'])
				->setExpireDate(new BitrixCalendarCoreBaseDate($data['EXPIRES']));
			$this->savePushChannel($pushChannel);
		}
		else
		{
			$result->addError(new Error('Error of create push channel.'));
		}
	}
	catch(ApiException $e)
	{
		$result->addError(new Error('ApiException during creation of push channel.'));
	    if ($e->getMessage() === 'ExtensionError')
		{
			$this->deleteChannel($pushChannel);
		}
		else
		{
			throw $e;
		}
	}
	return $result;
}