FileManager
class FileManager
File Manager
Methods
Create a new FileManager instance.
Create a new FileModelInterface instance, from the supportedFileModels table
A a new FileModelInterface class name to the supported class list.
Copy UploadedFile into the server storage directory
Save file into the database
Save file into the database
Sanitizes a filename replacing whitespace with dashes
Delete image from file storage and database
Rename file with image model id
Check if a file is an image Check based on mime type
Details
at line 37
__construct(
array $supportedFileModels)
Create a new FileManager instance.
at line 63
FileModelInterface
getModelInstance(
string $fileType,
string $parentType)
Create a new FileModelInterface instance, from the supportedFileModels table
at line 96
addFileModel(
string $fileType,
string $parentType,
string $fullyQualifiedClassName)
A a new FileModelInterface class name to the supported class list.
at line 111
UploadedFile|null
copyUploadedFile(
FileModelInterface $model,
UploadedFile $uploadedFile,
ConnectionInterface $con = null)
Copy UploadedFile into the server storage directory
at line 176
int
saveImage(
FileCreateOrUpdateEvent $event,
FileModelInterface $imageModel)
Save file into the database
at line 189
int
saveDocument(
FileCreateOrUpdateEvent $event,
FileModelInterface $documentModel)
Save file into the database
at line 205
string
sanitizeFileName(
string $string)
Sanitizes a filename replacing whitespace with dashes
Removes special characters that are illegal in filenames on certain operating systems and special characters requiring special escaping to manipulate at the command line.
at line 215
deleteFile(
FileModelInterface $model)
Delete image from file storage and database
at line 232
string
renameFile(
int $modelId,
UploadedFile $uploadedFile)
Rename file with image model id
at line 257
bool
isImage(
string $mimeType)
Check if a file is an image Check based on mime type