- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/integrity/duplicatebankdetailcriterion.php
- Класс: Bitrix\Crm\Integrity\DuplicateBankDetailCriterion
- Вызов: DuplicateBankDetailCriterion::bulkRegister
static function bulkRegister($entityTypeID, $entityID, array $data, $isRaw = true)
{
if(!is_int($entityTypeID))
{
throw new Main\ArgumentTypeException('entityTypeID', 'integer');
}
if(!is_int($entityID))
{
throw new Main\ArgumentTypeException('entityID', 'integer');
}
if(!$isRaw)
{
$effectiveData = $data;
}
else
{
$effectiveData = array();
foreach($data as $countryId => $fields)
{
if(is_array($fields))
{
foreach ($fields as $fieldName => $values)
{
if (is_array($values))
{
$effectiveData[$countryId][$fieldName] =
self::prepareCodes($countryId, $fieldName, $values);
}
}
}
}
}
DuplicateBankDetailMatchCodeTable::bulkReplaceValues($entityTypeID, $entityID, $effectiveData);
$typesToUnregister = array();
$scopesToUnregister = array();
foreach (self::getFieldsMap() as $countryId => $fields)
{
$scope = EntityBankDetail::formatDuplicateCriterionScope($countryId);
if (is_array($effectiveData[$countryId] ?? null) && !empty($effectiveData[$countryId]))
{
foreach ($fields as $fieldName)
{
$typeID = DuplicateIndexType::resolveID($fieldName);
if (is_array($effectiveData[$countryId][$fieldName] ?? null)
&& !empty($effectiveData[$countryId][$fieldName]))
{
DuplicateEntityMatchHash::unregisterEntity($entityTypeID, $entityID, $typeID, $scope);
foreach($effectiveData[$countryId][$fieldName] as $value)
{
DuplicateEntityMatchHash::register(
$entityTypeID, $entityID, $typeID,
self::prepareMatchHash(array(
'BD_COUNTRY_ID' => $countryId,
'BD_FIELD_NAME' => $fieldName,
'VALUE' => $value
)),
true, $scope
);
}
}
else
{
if (!is_array($typesToUnregister[$scope] ?? null))
{
$typesToUnregister[$scope] = [];
}
$typesToUnregister[$scope][] = $typeID;
}
}
}
else
{
if (!is_array($scopesToUnregister[$scope] ?? null))
{
$scopesToUnregister[$scope] = [];
}
foreach ($fields as $fieldName)
{
$typeID = DuplicateIndexType::resolveID($fieldName);
$scopesToUnregister[$scope][] = $typeID;
}
}
}
foreach ($typesToUnregister as $scope => $types)
{
DuplicateEntityMatchHash::unregisterEntity($entityTypeID, $entityID, $types, $scope);
}
foreach ($scopesToUnregister as $scope => $types)
{
DuplicateEntityMatchHash::unregisterEntity($entityTypeID, $entityID, $types, $scope);
}
}