class File (View source)

Service class for the File entity

Methods

static File|null
getByID(int $fID)

Return a file object for the given file ID.

static string|false
getRelativePathFromID(int $fID)

Return the relative path for a file (may not exist).

static Version
add(string $filename, string $prefix, array $data = [], StorageLocation|false $fsl = false, FileFolder|false $folder = false)

Create and persist a File entity and a File\Version entity (the filesystem file must already have been imported).

Details

static File|null getByID(int $fID)

Return a file object for the given file ID.

Parameters

int $fID

The file identifier

Return Value

File|null

static string|false getRelativePathFromID(int $fID)

Return the relative path for a file (may not exist).

Parameters

int $fID

The file identifier

Return Value

string|false

static Version add(string $filename, string $prefix, array $data = [], StorageLocation|false $fsl = false, FileFolder|false $folder = false)

Create and persist a File entity and a File\Version entity (the filesystem file must already have been imported).

Parameters

string $filename

The name of the file (without path, only the file name)

string $prefix

The concrete5 file prefix that has been used to store the file

array $data

{ @var int|null $uID The ID of the user to be set as the author of the file (if not specified, we'll use the currently logged in user) @var string $fvTitle The file title (if not specified, we'll assume an empty string) @var string $fvDescription The file description (if not specified, we'll assume an empty string) @var string $fvTags The tags to be associated to the file (separate multiple tags with commas or new lines) (if not specified, we'll assume no tags) @var bool $fvIsApproved The file title (if not specified, we'll assume an empty string) }

StorageLocation|false $fsl

The storage location to be used (we'll use the default one if it's falsy)

FileFolder|false $folder

The folder where the file must be added (we'll use the root folder if it's falsy)

Return Value

Version