/** * @return string */ public function getPath() { $method = 'getReadablePath'; if (is_callable([$this->resource->getParentFolder(), $method])) { return call_user_func([$this->resource->getParentFolder(), $method]); } return ''; }
/** * Moves a $file into a $targetFolder * the target folder has to be part of this storage * * previously in \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_move() * * @param FileInterface $file * @param Folder $targetFolder * @param string $targetFileName an optional destination fileName * @param string $conflictMode a value of the DuplicationBehavior enumeration * * @throws Exception\ExistingTargetFileNameException * @throws \RuntimeException * @return FileInterface */ public function moveFile($file, $targetFolder, $targetFileName = null, $conflictMode = DuplicationBehavior::RENAME) { $conflictMode = DuplicationBehavior::cast($conflictMode); if ($targetFileName === null) { $targetFileName = $file->getName(); } $originalFolder = $file->getParentFolder(); $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName); $this->assureFileMovePermissions($file, $targetFolder, $sanitizedTargetFileName); if ($targetFolder->hasFile($sanitizedTargetFileName)) { // File exists and we should abort, let's abort if ($conflictMode->equals(DuplicationBehavior::RENAME)) { $sanitizedTargetFileName = $this->getUniqueName($targetFolder, $sanitizedTargetFileName); } elseif ($conflictMode->equals(DuplicationBehavior::CANCEL)) { throw new Exception\ExistingTargetFileNameException('The target file already exists', 1329850997); } } $this->emitPreFileMoveSignal($file, $targetFolder); $sourceStorage = $file->getStorage(); // Call driver method to move the file and update the index entry try { if ($sourceStorage === $this) { $newIdentifier = $this->driver->moveFileWithinStorage($file->getIdentifier(), $targetFolder->getIdentifier(), $sanitizedTargetFileName); if (!$file instanceof AbstractFile) { throw new \RuntimeException('The given file is not of type AbstractFile.', 1384209025); } $file->updateProperties(array('identifier' => $newIdentifier)); } else { $tempPath = $file->getForLocalProcessing(); $newIdentifier = $this->driver->addFile($tempPath, $targetFolder->getIdentifier(), $sanitizedTargetFileName); $sourceStorage->driver->deleteFile($file->getIdentifier()); if ($file instanceof File) { $file->updateProperties(array('storage' => $this->getUid(), 'identifier' => $newIdentifier)); } } $this->getIndexer()->updateIndexEntry($file); } catch (\TYPO3\CMS\Core\Exception $e) { echo $e->getMessage(); } $this->emitPostFileMoveSignal($file, $targetFolder, $originalFolder); return $file; }
/** * Pre file delete * * @param FileInterface $file The file * * @return void */ public function preFileDelete(FileInterface $file) { $this->flushCacheForAffectedPages($file->getParentFolder()); }