CCrmInvoiceRestService::processEvent

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmInvoiceRestService
  4. processEvent
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice_invoice.php
  • Класс: \CCrmInvoiceRestService
  • Вызов: CCrmInvoiceRestService::processEvent
static function processEvent(array $arParams, array $arHandler)
{
	$eventName = $arHandler['EVENT_NAME'];
	if(mb_strpos(mb_strtoupper($eventName), 'ONCRMINVOICE') !== 0)
	{
		throw new RestException("The Event \"{$eventName}\" is not supported in current context");
	}

	$action = mb_substr($eventName, 12);
	if($action === false || $action === '')
	{
		throw new RestException("The Event \"{$eventName}\" is not supported in current context");
	}

	$action = mb_strtoupper($action);
	switch($action)
	{
		case 'ADD':
		case 'UPDATE':
		{
			$fields = isset($arParams[0]) ? $arParams[0] : null;
			$ID = is_array($fields) && isset($fields['ID']) ? (int)$fields['ID'] : 0;
		}
			break;
		case 'DELETE':
		{
			$ID = isset($arParams[0]) ? (int)$arParams[0] : 0;
		}
			break;
		case 'SETSTATUS':
		{
			$fields = isset($arParams[0]) ? $arParams[0] : null;
			$ID = is_array($fields) && isset($fields['ID']) ? (int)$fields['ID'] : 0;
		}
			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 array('FIELDS' => array('ID' => $ID));
}

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