/** * Adds link on file in folder. * @param File $sourceFile Source file. * @param array $data Contains additional fields (CREATED_BY, NAME, etc). * @param array $rights Rights (@see \Bitrix\Disk\RightsManager). * @param bool $generateUniqueName Generates unique name for object in directory. * @throws \Bitrix\Main\ArgumentException * @return File|null */ public function addFileLink(File $sourceFile, array $data, array $rights = array(), $generateUniqueName = false) { $this->errorCollection->clear(); $data = $this->prepareDataForAddLink($sourceFile, $data, $generateUniqueName); if (!$data) { return null; } $data['SIZE'] = $sourceFile->getSize(); /** @var FileLink $fileModel */ $fileLinkModel = FileLink::add($data, $this->errorCollection); if (!$fileLinkModel) { return null; } $driver = Driver::getInstance(); $driver->getRightsManager()->setAsNewLeaf($fileLinkModel, $rights); $driver->getIndexManager()->indexFile($fileLinkModel); $this->notifySonetGroup($fileLinkModel); return $fileLinkModel; }
protected static function getClassNameModel(array $row) { if (!isset($row['ID'])) { throw new ArgumentTypeException('Invalid ID'); } if (!isset($row['TYPE'])) { throw new ArgumentTypeException('Invalid TYPE'); } if (empty($row['REAL_OBJECT_ID']) || $row['REAL_OBJECT_ID'] == $row['ID']) { if ($row['TYPE'] == ObjectTable::TYPE_FILE) { return File::className(); } return Folder::className(); } if ($row['TYPE'] == ObjectTable::TYPE_FILE) { return FileLink::className(); } return FolderLink::className(); }