7use Bitrix\Disk\Internals\FileTable;
8use Bitrix\Disk\Storage;
9use Bitrix\Im\Model\EO_FileTemporary;
10use Bitrix\Im\Model\EO_FileTemporary_Collection;
28 public function __construct(?array $diskFiles =
null, ?
int $chatId =
null)
30 parent::__construct();
32 if ($diskFiles !==
null)
34 foreach ($diskFiles as $diskFile)
36 $this[] =
new FileItem($diskFile, $chatId);
53 if (empty($diskFilesIds) || !Loader::includeModule(
'disk'))
58 $diskFiles = File::getModelList([
59 'filter' => Query::filter()->whereIn(
'ID', $diskFilesIds)->where(
'TYPE', FileTable::TYPE)
62 return new static($diskFiles, $chatId);
65 public function getCopies(?Storage $storage =
null): self
67 $userId = $this->getContext()->getUserId();
68 $storage = $storage ?? Driver::getInstance()->getStorageByUserId($userId);
69 $copies =
new static();
71 foreach ($this as $fileEntity)
73 $copy = $fileEntity->getCopy($storage);
85 $tmpCollection =
new EO_FileTemporary_Collection();
87 foreach ($this as $file)
89 $tmpEntity =
new EO_FileTemporary([
'DISK_FILE_ID' => $file->getId(),
'SOURCE' => $source]);
90 $tmpCollection->add($tmpEntity);
93 $addResult = $tmpCollection->save(
true);
95 if (!$addResult->isSuccess())
97 return (
new Result())->addErrors($addResult->getErrors());
106 foreach ($this as $file)
108 $resultData[$file->getDiskFileId()] = \CIMDisk::GetFileParams($chatId, $file->getDiskFile(), $options = []);
118 return parent::getPopupData($excludedList)->merge($data);
static getRestEntityName()
getFileDiskAttributes(int $chatId, array $options=[])
getPopupData(array $excludedList=[])
getCopies(?Storage $storage=null)
__construct(?array $diskFiles=null, ?int $chatId=null)
static initByDiskFilesIds(array $diskFilesIds, ?int $chatId=null)