Tracker::convertBizprocTrackingToLog: Bitrix method

      
<?php 
//  Bitrix\Bizproc\Automation\Tracker :: convertBizprocTrackingToLog()
//  /dist/bitrix/modules/bizproc/lib/automation/tracker.php:37

    
private function convertBizprocTrackingToLog($entries$isCurrentStatus)
    {
        
$trigger null;
        
$robotEntries = array();
        
$robots = array();

        foreach (
$entries as $entry)
        {
            if (
$entry['TYPE'] == \CBPTrackingType::Trigger)
            {
                
$trigger = array(
                    
'ID' => $entry['ACTION_NOTE'],
                    
'STATUS' => static::STATUS_COMPLETED,
                    
'MODIFIED' => $entry['MODIFIED']
                );
            }
            else
            {
                
$robotEntries[$entry['ACTION_NAME']][] = $entry;
            }
        }

        foreach (
$robotEntries as $robotId => $robotEntry)
        {
            
$status = static::STATUS_WAITING;
            
$modified null;
            
$isExecute $isClosed $isAutocompleted false;
            
$executeTime $closedTime $autocompletedTime null;
            
$errors = array();
            
$notes = array();
            foreach (
$robotEntry as $entry)
            {
                if (
$entry['TYPE'] == \CBPTrackingType::ExecuteActivity)
                {
                    
$isExecute true;
                    
$executeTime $entry['MODIFIED'];
                }
                elseif (
$entry['TYPE'] == \CBPTrackingType::CloseActivity)
                {
                    
$isClosed true;
                    
$closedTime $entry['MODIFIED'];
                }
                elseif (
$entry['TYPE'] == \CBPTrackingType::Error)
                {
                    
$errors[] = $entry['ACTION_NOTE'];
                }
                elseif (
$entry['TYPE'] == \CBPTrackingType::Custom)
                {
                    
$notes[] = $entry['ACTION_NOTE'];
                }
            }

            if (
$isAutocompleted)
            {
                
$status = static::STATUS_AUTOCOMPLETED;
                
$modified $autocompletedTime;
            }
            elseif (
$isClosed)
            {
                
$status = static::STATUS_COMPLETED;
                
$modified $closedTime;
            }
            elseif (
$isExecute)
            {
                
$status $isCurrentStatus? static::STATUS_RUNNING : static::STATUS_COMPLETED;
                
$modified $executeTime;
            }

            
$robots[$robotId] = array(
                
'ID' => $robotId,
                
'STATUS' => $status,
                
'MODIFIED' => $modified,
                
'ERRORS' => $errors,
                
'NOTES' => $notes
            
);
        }

        return array(
            
'trigger' => $trigger,
            
'robots' => $robots
        
);
    }