Document::deleteAction

  1. Bitrix24 API (v. 23.675.0)
  2. catalog
  3. Document
  4. deleteAction
  • Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/controller/document.php
  • Класс: BitrixCatalogControllerDocument
  • Вызов: Document::deleteAction
public function deleteAction(int $id): ?bool
{
	if (!Feature::isInventoryManagementEnabled())
	{
		$this->addError(new Error(Loc::getMessage('DOCUMENT_CONTROLLER_NO_INVENTORY_MANAGEMENT_ENABLED_ERROR')));

		return null;
	}

	if (!$this->checkDocumentAccess(ActionDictionary::ACTION_STORE_DOCUMENT_DELETE, $id))
	{
		return null;
	}

	$deleteResult = CCatalogDocs::delete($id);
	if (!$deleteResult)
	{
		$message = Loc::getMessage('CATALOG_CONTROLLER_DOCUMENT_NOT_FOUND');

		$this->addError(
			new Error($message)
		);

		return null;
	}

	global $APPLICATION;
	if ($exception = $APPLICATION->getException())
	{
		if ($exception->getID() === CCatalogDocs::DELETE_CONDUCTED_ERROR)
		{
			$message = Loc::getMessage(
				'DOCUMENT_CONTROLLER_DELETE_CONDUCTED_ERROR',
				[
					'#DOC_TITLE#' => $id,
				]
			);
		}
		else
		{
			$message = Loc::getMessage(
				'DOCUMENT_CONTROLLER_DELETE_ERROR',
				[
					'#DOC_TITLE#' => $id,
					'#ERROR#' => htmlspecialcharsbx($exception->getString()),
				]
			);
		}

		$this->addError(
			new Error($message)
		);

		$APPLICATION->ResetException();

		return null;
	}

	return $deleteResult;
}

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