• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/controller/businessvaluepersondomain.php
  • Класс: BitrixSaleControllerBusinessValuePersonDomain
  • Вызов: BusinessValuePersonDomain::addAction
public function addAction(array $fields)
{
	$result = new Result();

	$personTypeId = $fields['PERSON_TYPE_ID'];
	$domain = $fields['DOMAIN'];

	$r = $this->personTypeExists($personTypeId);

	if($r->isSuccess())
	{
		$r = $this->exists($personTypeId);
		if($r->isSuccess())
		{
			$result->addError(new Error('Duplicate entry for key [personTypeId]', 201450000001));
		}
		else
		{
			BusinessValuePersonDomainTable::add(array(
				'PERSON_TYPE_ID' => $personTypeId,
				'DOMAIN' => $domain,
			));
		}
	}
	else
	{
		$result->addErrors($r->getErrors());
	}

	if($result->isSuccess())
	{
		return [
			'BUSINESS_VALUE_PERSON_DOMAIN'=>BusinessValuePersonDomainTable::getList(['filter'=>[
				'PERSON_TYPE_ID'=>$personTypeId,
				'DOMAIN'=>$domain
			]])->fetchAll()[0]
		];
	}
	else
	{
		$this->addErrors($result->getErrors());
		return null;
	}
}