- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
- Класс: CIMRestService
- Вызов: CIMRestService::bindEvent
static function bindEvent($appId, $appCode, $bitrixEventModule, $bitrixEventName, $restEventName, $restEventHandler)
{
$res = BitrixRestEventTable::getList(array(
'filter' => array(
'=EVENT_NAME' => toUpper($restEventName),
"=APPLICATION_TOKEN" => $appCode,
'=APP_ID' => $appId,
),
'select' => array('ID')
));
if ($handler = $res->fetch())
{
return true;
}
$result = BitrixRestEventTable::add(array(
"APP_ID" => $appId,
"EVENT_NAME" => toUpper($restEventName),
"EVENT_HANDLER" => $restEventHandler,
"APPLICATION_TOKEN" => $appCode,
"USER_ID" => 0,
));
if($result->isSuccess())
{
BitrixRestEventSender::bind($bitrixEventModule, $bitrixEventName);
}
return true;
}