• Модуль: rpa
  • Путь к файлу: ~/bitrix/modules/rpa/lib/controller/item.php
  • Класс: BitrixRpaControllerItem
  • Вызов: Item::getFileAction
public function getFileAction(BitrixRpaModelType $type, int $id, string $fieldName, int $file_id): ?BFile
{
	$item = $type->getItem($id);
	if(!$item)
	{
		$this->addError(new Error(Loc::getMessage('RPA_ITEM_NOT_FOUND_ERROR')));
		return null;
	}
	if(!Driver::getInstance()->getUserPermissions()->canViewItem($item))
	{
		$this->addError(new Error(Loc::getMessage('RPA_VIEW_ITEM_ACCESS_DENIED')));
		return null;
	}

	$userFieldCollection = $item->getType()->getUserFieldCollection();
	$userField = $userFieldCollection->getByName($fieldName);
	if (!$userField || !$userField->isBaseTypeFile())
	{
		$this->addError(new Error('Field ' . $fieldName . ' is not a file field'));
		return null;
	}

	$value = $item->get($fieldName);
	if(
		($value === $file_id)
		||
		(is_array($value) && in_array($file_id, $value))
	)
	{
		return BFile::createByFileId($file_id);
	}

	return null;
}