• Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/schedulerservice.php
  • Класс: CBPSchedulerService
  • Вызов: CBPSchedulerService::onEvent
static function onEvent($workflowId, $eventName, $arEventParameters = array())
{
	$num = func_num_args();
	if ($num > 3)
	{
		for ($i = 3; $i < $num; $i++)
			$arEventParameters[] = func_get_arg($i);
	}

	if (is_array($arEventParameters["EntityId"]))
	{
		foreach ($arEventParameters["EntityId"] as $key => $value)
		{
			if (!isset($arEventParameters[0][$key]) || $arEventParameters[0][$key] != $value)
				return;
		}
	}
	elseif ($arEventParameters["EntityId"] != null && $arEventParameters["EntityId"] != $arEventParameters[0])
		return;

	global $BX_MODULE_EVENT_LAST;
	$lastEvent = $BX_MODULE_EVENT_LAST;

	try
	{
		CBPRuntime::SendExternalEvent($workflowId, $eventName, $arEventParameters);
	}
	catch (Exception $e)
	{
		//Clean-up records if instance not found
		if (
			$e->getCode() === CBPRuntime::EXCEPTION_CODE_INSTANCE_NOT_FOUND
			&& $lastEvent['TO_MODULE_ID'] == 'bizproc'
			&& $lastEvent['TO_CLASS'] == 'CBPSchedulerService'
			&& $lastEvent['TO_METHOD'] == 'OnEvent'
			&& is_array($lastEvent['TO_METHOD_ARG'])
			&& $lastEvent['TO_METHOD_ARG'][0] == $workflowId
		)
		{
			UnRegisterModuleDependences(
				$lastEvent['FROM_MODULE_ID'],
				$lastEvent['MESSAGE_ID'],
				"bizproc",
				"CBPSchedulerService",
				"OnEvent",
				"",
				$lastEvent['TO_METHOD_ARG']
			);
		}
	}
}