AdvertAssetTrait
Advert-specific hooks for `AssetProcessingTrait` plus processing of file attachments.
Asset processing (image variants, watermark, relations) comes from the shared
AssetProcessingTrait; this trait holds only the advert bindings (subDir, dir keys,
variant type, rel factory).
Tags
Table of Contents
Methods
- createAssetRel() : object
- getAssetDirAbs() : string
- getAssetDirRel() : string
- getAssetSubDir() : string
- getAssetVariantType() : string
- guardNewFiles() : Result|null
- Gate for new attachments, called from `beforeSave()`, before the advert and files are written.
- processFiles() : Result|null
- Processes the ordered file list (existing and new in one array).
Methods
createAssetRel()
protected
createAssetRel(object $parent, Asset $asset, int $order, bool $isMain) : object
Parameters
- $parent : object
- $asset : Asset
- $order : int
- $isMain : bool
Return values
objectgetAssetDirAbs()
protected
getAssetDirAbs() : string
Return values
stringgetAssetDirRel()
protected
getAssetDirRel() : string
Return values
stringgetAssetSubDir()
protected
getAssetSubDir(int $parentId) : string
Parameters
- $parentId : int
Return values
stringgetAssetVariantType()
protected
getAssetVariantType() : string
Return values
stringguardNewFiles()
Gate for new attachments, called from `beforeSave()`, before the advert and files are written.
private
guardNewFiles(array<string, mixed> $meta) : Result|null
One forbidden file rejects the whole save (the user would not notice a silently dropped file). The rule is held by AttachmentFilePolicy; the dropzone is only UX, external clients call the API too.
Parameters
- $meta : array<string, mixed>
Return values
Result|nullprocessFiles()
Processes the ordered file list (existing and new in one array).
private
processFiles(Advert &$entity, array<int, array{type: string, fileId?: int, name?: string, data?: string, path?: string, order?: int}> $orderedFiles) : Result|null
Each item is {type: 'existing', fileId, order} or {type: 'new', name, data|path, order}
(path = a file in the dropzone temp folder, internal calls only).
Parameters
- $entity : Advert
- $orderedFiles : array<int, array{type: string, fileId?: int, name?: string, data?: string, path?: string, order?: int}>