CCrmDealRecurringRestProxy::processEvent

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmDealRecurringRestProxy
  4. processEvent
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmDealRecurringRestProxy
  • Вызов: CCrmDealRecurringRestProxy::processEvent
static function processEvent(array $arParams, array $arHandler)
{
	$event = $arParams[0];
	$eventFields = [];
	if ($event instanceof Main\Event)
	{
		$eventFields = $event->getParameters();
	}
	$eventName = mb_strtolower($arHandler['EVENT_NAME']);
	if ($eventName === 'oncrmdealrecurringexpose')
	{
		$id = isset($eventFields['ID']) ? (int)$eventFields['ID'] : 0;
		if($id <= 0)
		{
			throw new RestException("Could not find entity ID in fields of event \"{$eventName}\"");
		}

		$newDealId = isset($eventFields['DEAL_ID']) ? (int)$eventFields['DEAL_ID'] : 0;
		if($newDealId <= 0)
		{
			throw new RestException("Could not find new deal ID in fields of event \"{$eventName}\"");
		}

		$recurringId = isset($eventFields['RECURRING_ID']) ? (int)$eventFields['RECURRING_ID'] : 0;

		return [
			'FIELDS' => [
				'ID' => $id,
				'RECURRING_DEAL_ID' => $recurringId,
				'DEAL_ID' => $newDealId,
			]
		];
	}
	else
	{
		switch ($eventName)
		{
			case 'oncrmdealrecurringadd':
			case 'oncrmdealrecurringupdate':
				{
					$ID = isset($eventFields['ID']) ? (int)$eventFields['ID'] : 0;
					$dealId = isset($eventFields['DEAL_ID']) ? (int)$eventFields['DEAL_ID'] : 0;
					$resultFields = [
						'ID' => $ID,
						'RECURRING_DEAL_ID' => $dealId
					];
				}
				break;
			case 'oncrmdealrecurringdelete':
				{
					$ID = isset($eventFields['ID']) ? (int)$eventFields['ID'] : 0;
					$resultFields['ID'] = $ID;
				}
				break;
			default:
				throw new RestException("The Event \"{$eventName}\" is not supported in current context");
		}

		if($ID <= 0)
		{
			throw new RestException("Could not find entity ID in fields of event \"{$eventName}\"");
		}

		return ['FIELDS' => $resultFields];
	}
}

Добавить комментарий