CCrmMeasureRestProxy::processEvent

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmMeasureRestProxy
  4. processEvent
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmMeasureRestProxy
  • Вызов: CCrmMeasureRestProxy::processEvent
static function processEvent(array $arParams, array $arHandler)
{
	$eventName = $arHandler['EVENT_NAME'];
	switch(mb_strtolower($eventName))
	{
		case 'oncrmmeasureadd':
			if(!isset($arParams[0]) || !($arParams[0] instanceof Main\Entity\Event))
			{
				throw new RestException("Bad result of event \"{$eventName}\"");
			}
			/** @var Main\Entity\Event $event */
			$event = $arParams[0];
			$id = (int)$event->getParameter('id');
			unset($event);
			if($id <= 0)
			{
				throw new RestException("Could not find entity ID in fields of event \"{$eventName}\"");
			}
			else
			{
				return array('FIELDS' => array('ID' => $id));
			}
			break;
		case 'oncrmmeasureupdate':
		case 'oncrmmeasuredelete':
			if(!isset($arParams[0]) || !($arParams[0] instanceof Main\Entity\Event))
			{
				throw new RestException("Bad result of event \"{$eventName}\"");
			}
			/** @var Main\Entity\Event $event */
			$event = $arParams[0];
			$primary = $event->getParameter('id');
			unset($event);
			$id = (!empty($primary['ID'])? (int)$primary['ID'] : 0);
			if($id <= 0)
			{
				throw new RestException("Could not find entity ID in fields of event \"{$eventName}\"");
			}
			else
			{
				return array('FIELDS' => array('ID' => $id));
			}
			break;
		default:
			throw new RestException("The Event \"{$eventName}\" is not supported in current context");
	}
}

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