Template :: unConvertTemplate: Bitrix method

      
<?php 
//  Bitrix\Bizproc\Automation\Engine\Template :: unConvertTemplate()
//  /dist/bitrix/modules/bizproc/lib/automation/engine/template.php:455

    
protected function unConvertTemplate()
    {
        
$documentType $this->getDocumentType();
        
$this->template = [
            
'ID' => $this->getId(),
            
'MODULE_ID' => $documentType[0],
            
'ENTITY' => $documentType[1],
            
'DOCUMENT_TYPE' => $documentType[2],
            
'DOCUMENT_STATUS' => $this->template['DOCUMENT_STATUS'],
            
'AUTO_EXECUTE' => $this->autoExecuteType,
            
'TEMPLATE'     => [[
                
'Type' => 'SequentialWorkflowActivity',
                
'Name' => 'Template',
                
'Properties' => ['Title' => 'Bizproc Automation template'],
                
'Children' => []
            ]],
            
'PARAMETERS' => $this->template['PARAMETERS'],
            
'CONSTANTS' => $this->template['CONSTANTS'],
            
'SYSTEM_CODE'  => 'bitrix_bizproc_automation'
        
];

        if (
$this->robots)
        {
            
$parallelActivity $this->createParallelActivity();
            
$sequence $this->createSequenceActivity();

            foreach (
$this->robots as $i => $robot)
            {
                if (
$i !== && !$robot->isExecuteAfterPrevious())
                {
                    
$parallelActivity['Children'][] = $sequence;
                    
$sequence $this->createSequenceActivity();
                }

                
$delayInterval $robot->getDelayInterval();
                if (
$delayInterval && !$delayInterval->isNow())
                {
                    
$delayName $robot->getDelayName();
                    if (!
$delayName)
                    {
                        
$delayName Robot::generateName();
                        
$robot->setDelayName($delayName);
                    }

                    
$sequence['Children'][] = $this->createDelayActivity(
                        
$delayInterval->toActivityProperties($documentType),
                        
$delayName
                    
);
                }

                
$activity $robot->getBizprocActivity();
                
$condition $robot->getCondition();

                if (
$condition && count($condition->getItems()) > 0)
                {
                    
$activity $condition->createBizprocActivity($activity$documentType);
                }

                
$sequence['Children'][] = $activity;
            }

            
$parallelActivity['Children'][] = $sequence;

            if (
count($parallelActivity['Children']) < 2)
            {
                
$parallelActivity['Children'][] = $this->createSequenceActivity();
            }

            
$this->template['TEMPLATE'][0]['Children'][] = $parallelActivity;
        }
    }