CoolCMS API

File extends File
in package

Attributes
#[Entity]
#[Table]
$name: 'cms_system_files'
#[TableAlias]
'file'

Table of Contents

Properties

$fileExtension  : string|null
$fileName  : string
$id  : int|null
$insertDatetime  : DateTime
$path  : string
$translations  : Collection<int, FileText>

Methods

__construct()  : mixed
addTranslation()  : self
callInitMethods()  : void
Calls `init{TraitName}()` for every used trait that defines such a method.
getAllTraits()  : array<string, string>
Returns all traits the class uses, including those used by parent classes and nested traits.
getFileExtension()  : string|null
getFileName()  : string
getFullFileName()  : string
getFullPath()  : string
getId()  : int|null
getInsertDatetime()  : DateTime
getPath()  : string
getTranslation()  : FileText|null
Translation for the given language, or null.
getTranslations()  : Collection<int, FileText>
IMPORTANT: the setter must exist. `EntityHydrator::hydrateProperty()` fills the property only through `set<Prop>()` and silently skips a collection without a setter, so the per-language file names would not be hydrated into the front end entity at all.
isPersisted()  : bool
removeTranslation()  : self
setFileExtension()  : $this
setFileName()  : $this
setId()  : $this
setInsertDatetime()  : $this
setPath()  : $this
setTranslations()  : self
getTraitsRecursive()  : array<string, string>
Walks the trait list recursively and collects nested traits too.

Properties

$fileExtension

protected string|null $fileExtension = null
Attributes
#[Column]
$name: 'file_extension'
$type: 'string'
$length: 50
$nullable: true

$fileName

protected string $fileName = ''
Attributes
#[Column]
$name: 'file_name'
$type: 'string'
$length: 255

$id

protected int|null $id = null
Attributes
#[Column]
$name: 'file_id'
$type: 'integer'
$options: ['unsigned' => true]
#[GeneratedValue]
#[Id]

$insertDatetime

protected DateTime $insertDatetime = new DateTime()
Attributes
#[Column]
$name: 'insert_datetime'
$type: 'datetime'
#[ExternalReadonly]

$path

protected string $path = ''
Attributes
#[Column]
$name: 'path'
$type: 'string'
$length: 255

$translations

protected Collection<int, FileText> $translations
Attributes
#[CollectionOf]
\App\UI\Front\System\Models\Entities\FileText::class
$owned: true
#[OneToMany]
$targetEntity: \App\UI\Front\System\Models\Entities\FileText::class
$mappedBy: 'parent'
$cascade: ['persist', 'remove']
$orphanRemoval: true
$fetch: 'LAZY'

Methods

__construct()

public __construct() : mixed

addTranslation()

public addTranslation(FileText $translation) : self
Parameters
$translation : FileText
Return values
self

callInitMethods()

Calls `init{TraitName}()` for every used trait that defines such a method.

public callInitMethods() : void

getAllTraits()

Returns all traits the class uses, including those used by parent classes and nested traits.

public getAllTraits() : array<string, string>
Return values
array<string, string>

getFileExtension()

public getFileExtension() : string|null
Return values
string|null

getFileName()

public getFileName() : string
Return values
string

getFullFileName()

public getFullFileName() : string
Return values
string

getFullPath()

public getFullPath() : string
Return values
string

getInsertDatetime()

public getInsertDatetime() : DateTime
Return values
DateTime

getPath()

public getPath() : string
Return values
string

getTranslation()

Translation for the given language, or null.

public getTranslation(int $langId) : FileText|null
Parameters
$langId : int
Return values
FileText|null

getTranslations()

IMPORTANT: the setter must exist. `EntityHydrator::hydrateProperty()` fills the property only through `set<Prop>()` and silently skips a collection without a setter, so the per-language file names would not be hydrated into the front end entity at all.

public getTranslations() : Collection<int, FileText>

The write path is unchanged: only the front end File maps the collection, the Api and Admin File do not have it, so no write payload sends an empty collection and orphanRemoval has nothing to clean up.

Return values
Collection<int, FileText>

removeTranslation()

public removeTranslation(FileText $translation) : self
Parameters
$translation : FileText
Return values
self

setFileExtension()

public setFileExtension(string|null $fileExtension) : $this
Parameters
$fileExtension : string|null
Return values
$this

setFileName()

public setFileName(string $fileName) : $this
Parameters
$fileName : string
Return values
$this

setId()

public setId(int|null $id) : $this
Parameters
$id : int|null
Return values
$this

setInsertDatetime()

public setInsertDatetime(DateTime $insertDatetime) : $this
Parameters
$insertDatetime : DateTime
Return values
$this

setPath()

public setPath(string $path) : $this
Parameters
$path : string
Return values
$this

setTranslations()

public setTranslations(Collection<int, FileText>|array<int, FileText> $translations) : self
Parameters
$translations : Collection<int, FileText>|array<int, FileText>
Return values
self

getTraitsRecursive()

Walks the trait list recursively and collects nested traits too.

private static getTraitsRecursive(array<string, string> $traits) : array<string, string>
Parameters
$traits : array<string, string>
Return values
array<string, string>
On this page

Search results