• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/Service/Factory/Lead.php
  • Класс: Bitrix\Crm\Service\Factory\Lead
  • Вызов: Lead::getDeleteOperation
public function getDeleteOperation(Item $item, Context $context = null): Operation\Delete
{
	$operation = parent::getDeleteOperation($item, $context);

	$operation
		->addAction(
			Operation::ACTION_BEFORE_SAVE,
			new Operation\Action\Compatible\SendEvent\WithCancel\Delete('OnBeforeCrmLeadDelete')
		)
		->addAction(
			Operation::ACTION_AFTER_SAVE,
			new Operation\Action\ClearCache(
				'b_crm_lead',
				'crm_entity_name_' . $this->getEntityTypeId() . '_'
			)
		)
	;

	// the action works properly only in this case. otherwise, does basically nothing, since on time of execution all
	// activities either rebound to recycle bin entity or deleted immediately.
	// in most cases this action is not needed, was added to extend backwards compatibility
	if (!$this->isRecyclebinEnabled() && $this->isDeferredCleaningEnabled())
	{
		$operation
			->addAction(
				Operation::ACTION_AFTER_SAVE,
				new Operation\Action\Compatible\RebindActivitiesToClient($this->getSuccessfulStageId()),
			)
		;
	}

	$operation
		->addAction(
			Operation::ACTION_AFTER_SAVE,
			new Operation\Action\Compatible\SocialNetwork\ProcessDelete(),
		)
		->addAction(
			Operation::ACTION_AFTER_SAVE,
			new Operation\Action\Compatible\SendEvent\Delete('OnAfterCrmLeadDelete')
		)
	;

	return $operation;
}