CCrmRequisitePresetRestProxy::innerAdd

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmRequisitePresetRestProxy
  4. innerAdd
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmRequisitePresetRestProxy
  • Вызов: CCrmRequisitePresetRestProxy::innerAdd
protected function innerAdd(&$fields, &$errors, array $params = null)
{
	$entityTypeID = intval($this->resolveParam($fields, 'ENTITY_TYPE_ID'));

	if(!$this->isValidID($entityTypeID) || $entityTypeID !== EntityPreset::Requisite)
	{
		$errors[] = 'ENTITY_TYPE_ID is not defined or invalid.';
		return false;
	}

	if(!EntityPreset::checkCreatePermissionOwnerEntity($entityTypeID))
	{
		$errors[] = 'Access denied.';
		return false;
	}

	if (!$this->checkFields($fields, $sError))
	{
		$errors[] = $sError;
		return false;
	}

	$entity = self::getEntity();
	$result = $entity->add($fields);

	if (is_object($result))
	{
		if($result->isSuccess())
		{
			$result = $result->getId();
		}
		else
		{
			$errors = $result->getErrors();
			$result = false;
		}
	}
	else
	{
		$errors[] = 'Error when adding preset.';
		$result = false;
	}

	return $result;
}

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