Document::updateAction

  1. Bitrix24 API (v. 23.675.0)
  2. catalog
  3. Document
  4. updateAction
  • Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/controller/document.php
  • Класс: BitrixCatalogControllerDocument
  • Вызов: Document::updateAction
public function updateAction(int $id, array $fields): ?array
{
	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_MODIFY, $id))
	{
		return null;
	}

	$user = CurrentUser::get();
	if (!array_key_exists('MODIFIED_BY', $fields) || !$user->isAdmin())
	{
		$fields['MODIFIED_BY'] = $user->getId();
	}

	$result = CCatalogDocs::update($id, $fields);
	if (!$result)
	{
		global $APPLICATION;
		if ($APPLICATION->GetException())
		{
			$exception = $APPLICATION->GetException();
			$this->addError(new Error($exception->GetString()));
			$APPLICATION->ResetException();

			return null;
		}
	}

	return ['DOCUMENT' => $this->get($id)];
}

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