CoolCMS API

AssetPathTrait

Stores a file as a relative path only (string column, not an `Asset` entity).

For entities such as a user avatar or a legacy category/region image. Provides the getter and setter of assetPath (the string from the database) and a derived FtpAsset through getAssetFile().

The mapped property $assetPath is declared in the entity constructor (constructor promotion with #[ORM\Column(name: "asset_path")]), like in the other entity traits (IdentifiableTrait). Only the transient cache $assetFile lives here.

The names are getAssetFile() and $assetFile, not getAsset() and $asset: those belong to entities with a real Asset foreign key (e.g. Category::getAsset()), and FtpAsset coexists with them.

getAssetFile() builds the FtpAsset lazily. Doctrine fills properties by reflection and bypasses the setter, so an eager build in the setter would not run on a database load.

Table of Contents

Properties

$assetFile  : FtpAsset|null
Transient cache of the derived `FtpAsset` (not a database column).

Methods

getAssetFile()  : FtpAsset|null
Returns the `FtpAsset` derived from the path (lazy, works after Doctrine hydration too).
getAssetPath()  : string|null
setAssetPath()  : $this

Properties

Methods

getAssetFile()

Returns the `FtpAsset` derived from the path (lazy, works after Doctrine hydration too).

public getAssetFile() : FtpAsset|null
Return values
FtpAsset|null

getAssetPath()

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

setAssetPath()

public setAssetPath(string|null $assetPath) : $this
Parameters
$assetPath : string|null
Return values
$this
On this page

Search results