CBPSchedulerService :: sendEvents: Bitrix method

      
<?php 
//  CBPSchedulerService :: sendEvents()
//  /dist/bitrix/modules/bizproc/classes/general/schedulerservice.php:247

    
public static function sendEvents($eventModule$eventName$entityKey)
    {
        if (
$eventModule === 'bizproc' && $eventName === 'OnWorkflowComplete' && $entityKey === null)
        {
            
//delete invalid subscription
            
UnRegisterModuleDependences(
                
$eventModule,
                
$eventName,
                
'bizproc',
                
'CBPSchedulerService',
                
'sendEvents',
                
'',
                array(
$eventModule$eventName$entityKey)
            );

            return 
false;
        }

        
$eventParameters = array(
            
'SchedulerService' => 'OnEvent',  // compatibility
            
'eventModule' => $eventModule,
            
'eventName' => $eventName
        
);

        
$num func_num_args();
        if (
$num 3)
        {
            for (
$i 3$i $num$i++)
                
$eventParameters[] = func_get_arg($i);
        }

        
$filter = array(
            
'=EVENT_MODULE' => $eventModule,
            
'=EVENT_TYPE' => $eventName
        
);

        
$entityId null;
        if (
$entityKey === && isset($eventParameters[0]))
            
$entityId = (string)$eventParameters[0];
        elseif (
$entityKey !== null && isset($eventParameters[0][$entityKey]))
            
$entityId = (string)$eventParameters[0][$entityKey];

        if (
$entityId !== null)
            
$filter['=ENTITY_ID'] = $entityId;

        
$iterator SchedulerEventTable::getList(array(
            
'filter' => $filter
        
));

        while (
$event $iterator->fetch())
        {
            
$event['EVENT_PARAMETERS'] = $eventParameters;
            
self::sendEventToWorkflow($event);
        }
    }