Template::save: Bitrix method

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

    
public function save(array $robots$userId)
    {
        
$userId = (int)$userId;
        
$result = new Result();
        
$templateId = !empty($this->template['ID']) ? $this->template['ID'] : 0;

        
$this->setRobots($robots);

        
$templateResult $templateId ?
            
$this->updateBizprocTemplate($templateId$userId) : $this->addBizprocTemplate($userId);

        if (
$templateResult->isSuccess())
        {
            
$resultData $templateResult->getData();
            if (isset(
$resultData['ID']))
            {
                
$this->template['ID'] = $resultData['ID'];
            }
        }
        else
        {
            
$result->addErrors($templateResult->getErrors());
        }

        return 
$result;
    }