• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/controller/item.php
  • Класс: Bitrix\Crm\Controller\Item
  • Вызов: Item::deleteAction
public function deleteAction(int $entityTypeId, int $id): ?array
{
	$factory = $this->getFactory($entityTypeId);
	if (!$factory)
	{
		return null;
	}
	$item = $factory->getItem($id);
	if (!$item)
	{
		$this->addError(new Error(
			Loc::getMessage('CRM_TYPE_ITEM_NOT_FOUND'),
			ErrorCode::NOT_FOUND
		));
		return null;
	}
	if (!Container::getInstance()->getUserPermissions()->canDeleteItem($item))
	{
		$this->addError(\Bitrix\Crm\Controller\ErrorCode::getAccessDeniedError());

		return null;
	}

	$categoryId = $item->getCategoryId();

	$operation = $factory->getDeleteOperation($item);
	$result = $operation->launch();
	if (!$result->isSuccess())
	{
		$this->addErrors($result->getErrors());
		return null;
	}

	if ($this->getScope() === static::SCOPE_AJAX)
	{
		return [
			'redirectUrl' => Container::getInstance()->getRouter()
				->getItemListUrlInCurrentView($entityTypeId, $categoryId),
		];
	}

	return [];
}