CodeExplorer renameFile example
$this->
doRenameMedia($currentMedia,
$destination,
$context);
} private function doRenameMedia(MediaEntity
$currentMedia, string
$destination, Context
$context): void
{ $updatedMedia =
clone $currentMedia;
$updatedMedia->
setFileName($destination);
$updatedMedia->
setUploadedAt(new \
DateTime());
try { $renamedFiles =
$this->
renameFile( $this->urlGenerator->
getRelativeMediaUrl($currentMedia),
$this->urlGenerator->
getRelativeMediaUrl($updatedMedia),
$this->
getFileSystem($currentMedia) );
} catch (\Exception
) { throw MediaException::
couldNotRenameFile($currentMedia->
getId(),
(string) $currentMedia->
getFileName());
} foreach ($currentMedia->
getThumbnails() ??
[] as $thumbnail) { try { $renamedFiles =
[...
$renamedFiles, ...
$this->
renameThumbnail($thumbnail,
$currentMedia,
$updatedMedia)];
}