DuplicateIndexBuilder::processEntityDeletion

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. DuplicateIndexBuilder
  4. processEntityDeletion
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integrity/duplicateindexbuilder.php
  • Класс: Bitrix\Crm\Integrity\DuplicateIndexBuilder
  • Вызов: DuplicateIndexBuilder::processEntityDeletion
public function processEntityDeletion(DuplicateCriterion $criterion, $entityID, array $params = array())
{
	if(!is_int($entityID))
	{
		$entityID = (int)$entityID;
	}

	if($entityID <= 0)
	{
		return;
	}

	$matchHash = $criterion->getMatchHash();

	$userID = $this->getUserID();
	$entityTypeID = $this->getEntityTypeID();
	$rootEntityID = $this->getRootEntityID($matchHash);
	$enablePermissionCheck = $this->isPermissionCheckEnabled();

	//Actual root entity is required for manual merging. User can select any entity as root entity.
	$actualRootEntityID = isset($params['ROOT_ENTITY_ID']) ? (int)$params['ROOT_ENTITY_ID'] : 0;
	if($actualRootEntityID <= 0)
	{
		$actualRootEntityID = $rootEntityID;
	}

	$quantity = $criterion->getActualCount($entityTypeID, $actualRootEntityID, $userID, $enablePermissionCheck, 100);
	if($quantity === 0)
	{
		$this->deleteDuplicateIndexByFilter(
			array(
				'USER_ID' => $this->getUserID(),
				'ENTITY_TYPE_ID' => $this->getEntityTypeID(),
				'TYPE_ID' => $this->typeID,
				'MATCH_HASH' => $matchHash
			)
		);
		return;
	}

	if($entityID !== $rootEntityID)
	{
		return;
	}

	// if $entityID == ROOT_ENTITY_ID,
	// reassign ROOT_ENTITY_ID or remove record from index because $entityID was deleted:
	$this->buildDuplicateByMatchHash($matchHash);
}

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