CBPRestActivity :: OnExternalEvent: Bitrix method

      
<?php 
//  CBPRestActivity :: OnExternalEvent()
//  /dist/bitrix/modules/bizproc/classes/general/restactivity.php:253

    
public function OnExternalEvent($eventParameters = array())
    {
        if (
$this->executionStatus == CBPActivityExecutionStatus::Closed)
            return;

        
$onAgent = (array_key_exists('SchedulerService'$eventParameters) && $eventParameters['SchedulerService'] == 'OnAgent');
        if (
$onAgent)
        {
            
$this->IsTimeout 1;
            
$this->Unsubscribe($this);
            
$this->workflow->CloseActivity($this);
            return;
        }

        if (
$this->eventId !== (string) $eventParameters['EVENT_ID'])
            return;

        if (!empty(
$eventParameters['RETURN_VALUES']))
        {
            
$activityData self::getRestActivityData();
            
$whiteList = array();
            if (!empty(
$activityData['RETURN_PROPERTIES']))
            {
                foreach (
$activityData['RETURN_PROPERTIES'] as $name => $property)
                {
                    
$whiteList[strtoupper($name)] = $name;
                }
            }

            
/** @var CBPDocumentService $documentService */
            
$documentService $this->workflow->GetService('DocumentService');
            
$eventParameters['RETURN_VALUES'] = array_change_key_case((array) $eventParameters['RETURN_VALUES'], CASE_UPPER);
            foreach(
$eventParameters['RETURN_VALUES'] as $name => $value)
            {
                if (!isset(
$whiteList[$name]))
                    continue;

                
$property $activityData['RETURN_PROPERTIES'][$whiteList[$name]];
                if (
$property && $value)
                {
                    
$property Bizproc\FieldType::normalizeProperty($property);
                    
$fieldTypeObject $documentService->getFieldTypeObject($this->GetDocumentType(), $property);
                    if (
$fieldTypeObject)
                    {
                        
$fieldTypeObject->setDocumentId($this->GetDocumentId());
                        
$value $fieldTypeObject->internalizeValue($this->GetName(), $value);
                    }
                }

                
$this->__set($whiteList[$name], $value);
            }
        }

        
$this->WriteToTrackingService(
            !empty(
$eventParameters['LOG_MESSAGE']) ? $eventParameters['LOG_MESSAGE']
                : 
Loc::getMessage('BPRA_DEFAULT_LOG_MESSAGE'));

        if (empty(
$eventParameters['LOG_ACTION']))
        {
            
$this->Unsubscribe($this);
            
$this->workflow->CloseActivity($this);
        }
    }