• Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/lib/automation/engine/template.php
  • Класс: BitrixBizprocAutomationEngineTemplate
  • Вызов: Template::save
public function save(array $robots, $userId, array $additional = [])
{
	$userId = (int)$userId;
	$result = new Result();
	$templateId = !empty($this->template['ID']) ? $this->template['ID'] : 0;

	if (isset($additional['PARAMETERS']) && is_array($additional['PARAMETERS']))
	{
		$this->template['PARAMETERS'] = $additional['PARAMETERS'];
	}
	if (isset($additional['CONSTANTS']) && is_array($additional['CONSTANTS']))
	{
		$this->template['CONSTANTS'] = $additional['CONSTANTS'];
	}

	if ($templateId)
	{
		$templateResult = $this->updateTemplateRobots($robots, $userId);
	}
	else
	{
		$this->setRobots($robots);
		$templateResult = $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;
}