• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/control/handler/templatefieldhandler.php
  • Класс: BitrixTasksControlHandlerTemplateFieldHandler
  • Вызов: TemplateFieldHandler::prepareBaseTemplate
public function prepareBaseTemplate(): self
{
	if (!isset($this->fields['BASE_TEMPLATE_ID']))
	{
		return $this;
	}

	if (!intval($this->fields['BASE_TEMPLATE_ID']))
	{
		return $this;
	}

	try
	{
		$baseTemplate = TemplateTable::getById($this->fields['BASE_TEMPLATE_ID'])->fetch();

		if (!$baseTemplate)
		{
			throw new TemplateFieldValidateException(Loc::getMessage("TASKS_TEMPLATE_BASE_TEMPLATE_ID_NOT_EXISTS"));
		}

		// you cannot add a template with both PARENT_ID and BASE_TEMPLATE_ID set. BASE_TEMPLATE_ID has greather priority
		if(isset($this->fields['PARENT_ID']))
		{
			$this->fields['PARENT_ID'] = '';
		}

		// you cannot add REPLICATE parameters here in case of BASE_TEMPLATE_ID is set
		if(isset($this->fields['REPLICATE']))
		{
			$this->fields['REPLICATE'] = 'N';
		}

		$this->fields['REPLICATE_PARAMS'] = [];
	}
	catch(BitrixMainArgumentException $e)
	{
		throw new TemplateFieldValidateException(Loc::getMessage("TASKS_TEMPLATE_BAD_BASE_TEMPLATE_ID"));
	}

	return $this;
}