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
$assetFile
Transient cache of the derived `FtpAsset` (not a database column).
private
FtpAsset|null
$assetFile
= null
Attributes
- #[Transient]
Methods
getAssetFile()
Returns the `FtpAsset` derived from the path (lazy, works after Doctrine hydration too).
public
getAssetFile() : FtpAsset|null
Return values
FtpAsset|nullgetAssetPath()
public
getAssetPath() : string|null
Return values
string|nullsetAssetPath()
public
setAssetPath(string|null $assetPath) : $this
Parameters
- $assetPath : string|null