• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/rest.php
  • Класс: CSocNetGroupSubjectRestProxy
  • Вызов: CSocNetGroupSubjectRestProxy::processEvent
static function processEvent(array $arParams, array $arHandler): array
{
	static $processedIdList = array();

	$eventName = $arHandler['EVENT_NAME'];

	$appKey = $arHandler['APP_ID'].$arHandler['APPLICATION_TOKEN'];
	if (!isset($processedIdList[$appKey]))
	{
		$processedIdList[$appKey] = array();
	}

	switch(mb_strtolower($eventName))
	{
		case 'onsonetgroupsubjectadd':
		case 'onsonetgroupsubjectupdate':
		case 'onsonetgroupsubjectdelete':

			$id = (int)($arParams[0] ?? 0);

			if ($id <= 0)
			{
				throw new RestException('Could not find sonet group subject ID in fields of event "' . $eventName . '"');
			}

			if (
				mb_strtolower($eventName) === 'onsonetgroupsubjectupdate'
				&& in_array($id, $processedIdList[$appKey], true)
			)
			{
				throw new RestException('ID '. $id . 'has already been processed');
			}

			if (in_array(mb_strtolower($eventName), array('onsonetgroupsubjectadd', 'onsonetgroupsubjectupdate')))
			{
				$processedIdList[$appKey][] = $id;
			}

			return array('FIELDS' => array('ID' => $id));
		default:
			throw new RestException("Incorrect handler ID");
	}
}