DuplicateBankDetailCriterion::checkIndex

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. DuplicateBankDetailCriterion
  4. checkIndex
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integrity/duplicatebankdetailcriterion.php
  • Класс: Bitrix\Crm\Integrity\DuplicateBankDetailCriterion
  • Вызов: DuplicateBankDetailCriterion::checkIndex
static function checkIndex(array $params)
{
	$entityTypeID = isset($params['ENTITY_TYPE_ID']) ? intval($params['ENTITY_TYPE_ID']) : \CCrmOwnerType::Undefined;
	if($entityTypeID !== \CCrmOwnerType::Undefined
		/*&& $entityTypeID !== \CCrmOwnerType::Lead*/
		&& $entityTypeID !== \CCrmOwnerType::Contact
		&& $entityTypeID !== \CCrmOwnerType::Company)
	{
		throw new Main\NotSupportedException("Entity type: '".\CCrmOwnerType::ResolveName($entityTypeID)."' is not supported in current context");
	}

	$typeID = isset($params['TYPE_ID']) ? intval($params['TYPE_ID']) : DuplicateIndexType::UNDEFINED;
	if(!in_array($typeID, self::getSupportedDedupeTypes(), true))
	{
		throw new Main\NotSupportedException("Criterion type(s): '".DuplicateIndexType::resolveName($typeID)."' is not supported in current context");
	}

	$userID = isset($params['USER_ID']) ? intval($params['USER_ID']) : 0;

	$scope = null;
	if (isset($params['SCOPE']))
	{
		$scope = $params['SCOPE'];
		if (!DuplicateIndexType::checkScopeValue($scope))
		{
			throw new Main\ArgumentException("Parameter has invalid value", 'SCOPE');
		}
	}

	$filter = array(
		'=USER_ID' => $userID,
		'=ENTITY_TYPE_ID' => $entityTypeID,
		'=TYPE_ID' => $typeID
	);
	if ($scope !== null)
		$filter['=SCOPE'] = $scope;

	$listParams = array(
		'select' => array('USER_ID', 'TYPE_ID', 'ENTITY_TYPE_ID'),
		'order' => array('USER_ID'=>'ASC', 'TYPE_ID'=>'ASC', 'ENTITY_TYPE_ID'=>'ASC'),
		'filter' => $filter,
		'limit' => 1
	);

	$dbResult = Entity\DuplicateIndexTable::getList($listParams);

	return is_array($dbResult->fetch());
}

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