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 File|null
getByUUID(int $fUUID)

Return a file object for the given file UUID.

static File|null
getByUUIDOrID($id)

Returns a file object in several conditions. If a UUID is given, we only check using that method.

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 File|null getByUUID(int $fUUID)

Return a file object for the given file UUID.

Parameters

int $fUUID

The file unique identifier

Return Value

File|null

static File|null getByUUIDOrID($id)

Returns a file object in several conditions. If a UUID is given, we only check using that method.

Otherwise, if an integer is given, we retrieve the object first. Then, we check to see if a UUID is present on the file. If a UUID is not present, we return the object. If it is present, we do not, because this file is no longer accessible via the numerical ID when using this method.

Parameters

$id

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