ComplaintFileUploaderTrait
Multi-upload of complaint attachments through a single static dropzone.
Unlike Bazaar AdvertUploaderTrait (one uploader per parameter), a complaint has no parameter
form, only one field. The Api afterSave performs the writes through meta['files']
(ComplaintFileTrait).
UploaderDropzone itself prevents a pending upload from being wiped on re-render
(UploaderDropzone::getPendingUploadNames()); the only requirement is not to call
prepareTempDir(forceNew: true) on an AJAX re-render (getSignal() !== null). The token is
taken over from POST instead (see resolveComplaintFileUploaderToken()).
Table of Contents
Methods
- createComponentFileUploader() : UploaderDropzone
- addComplaintFileUploaderFields() : void
- buildComplaintFilesMeta() : array<int, array{type: string, fileId?: int, name?: string, path?: string, order: int}>|null
- Builds `meta['files']` for the Api `afterSave`: existing ids plus new files as a `path` into the temp folder, sorted.
- cleanupComplaintFileUploader() : void
- configureComplaintFileUploader() : void
- prepareExistingComplaintFiles() : array<int, array{imageId: int, thumbPath: string, fileName: string, isMain: bool, order: int}>
- resolveComplaintFileUploaderToken() : string|null
Methods
createComponentFileUploader()
protected
createComponentFileUploader() : UploaderDropzone
Return values
UploaderDropzoneaddComplaintFileUploaderFields()
private
addComplaintFileUploaderFields(Form $form) : void
Parameters
- $form : Form
buildComplaintFilesMeta()
Builds `meta['files']` for the Api `afterSave`: existing ids plus new files as a `path` into the temp folder, sorted.
private
buildComplaintFilesMeta(ArrayHash<string|int, mixed> $values) : array<int, array{type: string, fileId?: int, name?: string, path?: string, order: int}>|null
An empty list is a legitimate instruction to remove all attachments (the user deleted even the
last one). Therefore "unknown" (no uploader in the form) is returned as null and the caller
leaves the files key out of meta; otherwise a missing component would delete the links
(ComplaintManager::afterSave()).
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
array<int, array{type: string, fileId?: int, name?: string, path?: string, order: int}>|nullcleanupComplaintFileUploader()
private
cleanupComplaintFileUploader() : void
configureComplaintFileUploader()
private
configureComplaintFileUploader(UploaderDropzone $uploader) : void
Parameters
- $uploader : UploaderDropzone
prepareExistingComplaintFiles()
private
prepareExistingComplaintFiles() : array<int, array{imageId: int, thumbPath: string, fileName: string, isMain: bool, order: int}>
Return values
array<int, array{imageId: int, thumbPath: string, fileName: string, isMain: bool, order: int}>resolveComplaintFileUploaderToken()
private
resolveComplaintFileUploaderToken() : string|null