Пример #1
0
 /**
  * Previously in \TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_rename()
  *
  * @param FileInterface $file
  * @param string $targetFileName
  *
  * @throws Exception\InsufficientFileWritePermissionsException
  * @throws Exception\InsufficientFileReadPermissionsException
  * @throws Exception\InsufficientUserPermissionsException
  * @return FileInterface
  */
 public function renameFile($file, $targetFileName)
 {
     // @todo add $conflictMode setting
     // The name should be different from the current.
     if ($file->getName() === $targetFileName) {
         return $file;
     }
     $sanitizedTargetFileName = $this->driver->sanitizeFileName($targetFileName);
     $this->assureFileRenamePermissions($file, $sanitizedTargetFileName);
     $this->emitPreFileRenameSignal($file, $sanitizedTargetFileName);
     // Call driver method to rename the file and update the index entry
     try {
         $newIdentifier = $this->driver->renameFile($file->getIdentifier(), $sanitizedTargetFileName);
         if ($file instanceof File) {
             $file->updateProperties(array('identifier' => $newIdentifier));
         }
         $this->getIndexer()->updateIndexEntry($file);
     } catch (\RuntimeException $e) {
     }
     $this->emitPostFileRenameSignal($file, $sanitizedTargetFileName);
     return $file;
 }