CBPSchedulerService::subscribeOnEvent

  1. Bitrix24 API (v. 23.675.0)
  2. bizproc
  3. CBPSchedulerService
  4. subscribeOnEvent
  • Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/schedulerservice.php
  • Класс: CBPSchedulerService
  • Вызов: CBPSchedulerService::subscribeOnEvent
public function subscribeOnEvent($workflowId, $eventHandlerName, $eventModule, $eventName, $entityId = null): ?int
{
	$resultId = null;
	$entityKey = null;
	if (is_array($entityId))
	{
		foreach ($entityId as $entityKey => $entityId)
			break;
	}
	elseif ($entityId !== null)
	{
		$entityKey = 0;
	}

	if (is_array($entityId))
	{
		$entityId = current(CBPHelper::makeArrayFlat($entityId));
	}

	if (!SchedulerEventTable::isSubscribed($workflowId, $eventHandlerName, $eventModule, $eventName, $entityId))
	{
		$result = SchedulerEventTable::add(array(
			'WORKFLOW_ID' => (string)$workflowId,
			'HANDLER' => (string)$eventHandlerName,
			'EVENT_MODULE' => (string)$eventModule,
			'EVENT_TYPE' => (string)$eventName,
			'ENTITY_ID' => (string)$entityId
		));
		$resultId = (int)$result->getId();
	}

	RegisterModuleDependences(
		$eventModule,
		$eventName,
		'bizproc',
		'CBPSchedulerService',
		'sendEvents',
		100,
		'',
		array($eventModule, $eventName, $entityKey)
	);

	return $resultId;
}

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