TemplateFieldHandler::prepareType

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. TemplateFieldHandler
  4. prepareType
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/control/handler/templatefieldhandler.php
  • Класс: BitrixTasksControlHandlerTemplateFieldHandler
  • Вызов: TemplateFieldHandler::prepareType
public function prepareType(): self
{
	if (
		$this->templateId
		&& !array_key_exists('TPARAM_TYPE', $this->fields)
	)
	{
		return $this;
	}

	if (
		$this->templateId
		&& (int) $this->fields['TPARAM_TYPE'] !== (int) $this->templateData['TPARAM_TYPE']
	)
	{
		throw new TemplateFieldValidateException('You can not change TYPE of an existing template');
	}

	if (
		($this->fields['TPARAM_TYPE'] ?? null)
		&& (int) $this->fields['TPARAM_TYPE'] !== CTaskTemplates::TYPE_FOR_NEW_USER
	)
	{
		throw new TemplateFieldValidateException('Unknown template type id passed');
	}

	if (
		(
			!$this->templateId
			&& (int)($this->fields['TPARAM_TYPE'] ?? null) === CTaskTemplates::TYPE_FOR_NEW_USER
		)
		||
		(
			$this->templateId
			&& (int)($this->templateData['TPARAM_TYPE'] ?? null) === CTaskTemplates::TYPE_FOR_NEW_USER
		)
	)
	{
		$this->fields['BASE_TEMPLATE_ID'] = '';
		$this->fields['REPLICATE_PARAMS'] = [];
		$this->fields['RESPONSIBLE_ID'] = '0';
		$this->fields['RESPONSIBLES'] = [0];
		$this->fields['MULTITASK'] = 'N';
	}

	return $this;
}

Добавить комментарий