• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/cleaning/cleaner.php
  • Класс: Bitrix\Crm\Cleaning\Cleaner
  • Вызов: Cleaner::cleanup
public function cleanup(): Result
{
	/*
	 * be aware that this method can run even after dynamic type deletion
	 * this means that there is no factory for such entityTypeId and \CCrmOwnerType::IsDefined(entityTypeId) returns false
	 * in most cases, if you just delete something by filter =ENTITY_TYPE_ID, you will be fine
	 * but remember this note and make sure that code that you place here handles this case correctly
	 */

	(new \CCrmFieldMulti())->DeleteByElement(
		\CCrmOwnerType::ResolveName($this->getEntityTypeId()),
		$this->getEntityId()
	);
	ProductRowTable::deleteByItem($this->getEntityTypeId(), $this->getEntityId());
	Kanban\SortTable::clearEntity($this->getEntityId(), \CCrmOwnerType::ResolveName($this->getEntityTypeId()));
	EntityPermsTable::clearByEntity(\CCrmOwnerType::ResolveName($this->getEntityTypeId()), $this->getEntityId());
	TimelineEntry::deleteByOwner($this->getEntityTypeId(), $this->getEntityId());
	EventRelationsTable::deleteByItem($this->getEntityTypeId(), $this->getEntityId());
	\CCrmActivity::DeleteByOwner($this->getEntityTypeId(), $this->getEntityId());
	Requisite\EntityLink::unregister($this->getEntityTypeId(), $this->getEntityId());
	UtmTable::deleteEntityUtm($this->getEntityTypeId(), $this->getEntityId());
	Tracking\Entity::deleteTrace($this->getEntityTypeId(), $this->getEntityId());
	Ml\Scoring::onEntityDelete($this->getEntityTypeId(), $this->getEntityId());
	Relation\EntityRelationTable::deleteByItem($this->getEntityTypeId(), $this->getEntityId());
	Pseudoactivity\WaitEntry::deleteByOwner($this->getEntityTypeId(), $this->getEntityId());
	Integration\Im\Chat::deleteChat([
		'ENTITY_TYPE_ID' => $this->getEntityTypeId(),
		'ENTITY_ID' => $this->getEntityId(),
	]);
	Badge::deleteByEntity(new ItemIdentifier($this->getEntityTypeId(), $this->getEntityId()));
	FieldContentTypeTable::deleteByItem(new ItemIdentifier($this->getEntityTypeId(), $this->getEntityId()));

	return $this->runJobs();
}