|
1
|
|
|
<?php |
|
2
|
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace BristolSU\Module\UploadFile\Events; |
|
5
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
use BristolSU\Module\UploadFile\Models\File; |
|
8
|
|
|
use BristolSU\Support\Action\Contracts\TriggerableEvent; |
|
9
|
|
|
|
|
10
|
|
|
class StatusChanged implements TriggerableEvent |
|
|
|
|
|
|
11
|
|
|
{ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
|
|
|
|
|
14
|
|
|
* @var File |
|
15
|
|
|
*/ |
|
16
|
|
|
public $file; |
|
17
|
|
|
|
|
18
|
6 |
|
public function __construct(File $file) |
|
|
|
|
|
|
19
|
|
|
{ |
|
20
|
6 |
|
$this->file = $file; |
|
21
|
6 |
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
|
|
|
|
|
24
|
|
|
* @inheritDoc |
|
25
|
|
|
*/ |
|
|
|
|
|
|
26
|
2 |
|
public function getFields(): array |
|
27
|
|
|
{ |
|
28
|
|
|
return [ |
|
29
|
2 |
|
'file_id' => $this->file->id, |
|
30
|
2 |
|
'title' => $this->file->title, |
|
31
|
2 |
|
'description' => $this->file->description, |
|
32
|
2 |
|
'filename' => $this->file->filename, |
|
33
|
2 |
|
'mime' => $this->file->mime, |
|
34
|
2 |
|
'size' => $this->file->size, |
|
35
|
2 |
|
'uploaded_by_id' => $this->file->uploaded_by->id(), |
|
|
|
|
|
|
36
|
2 |
|
'uploaded_by_email' => $this->file->uploaded_by->data()->email(), |
|
37
|
2 |
|
'uploaded_by_first_name' => $this->file->uploaded_by->data()->firstName(), |
|
38
|
2 |
|
'uploaded_by_last_name' => $this->file->uploaded_by->data()->lastName(), |
|
39
|
2 |
|
'uploaded_by_preferred_name' => $this->file->uploaded_by->data()->preferredName(), |
|
40
|
2 |
|
'module_instance_id' => $this->file->module_instance_id, |
|
41
|
2 |
|
'activity_instance_id' => $this->file->activity_instance_id, |
|
42
|
2 |
|
'uploaded_at' => $this->file->created_at->format('Y-m-d H:i:s'), |
|
43
|
2 |
|
'updated_at' => $this->file->updated_at->format('Y-m-d H:i:s'), |
|
44
|
2 |
|
'status' => $this->file->status |
|
45
|
|
|
]; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
|
|
|
|
|
49
|
|
|
* @inheritDoc |
|
50
|
|
|
*/ |
|
|
|
|
|
|
51
|
1 |
|
public static function getFieldMetaData(): array |
|
52
|
|
|
{ |
|
53
|
|
|
return [ |
|
54
|
|
|
'file_id' => [ |
|
55
|
1 |
|
'label' => 'File ID', |
|
56
|
|
|
'helptext' => 'The ID of the file' |
|
57
|
|
|
], |
|
58
|
|
|
'title' => [ |
|
59
|
|
|
'label' => 'Title', |
|
60
|
|
|
'helptext' => 'The title given to the document when uploaded', |
|
61
|
|
|
], |
|
62
|
|
|
'description' => [ |
|
63
|
|
|
'label' => 'Description', |
|
64
|
|
|
'helptext' => 'A description of the file' |
|
65
|
|
|
], |
|
66
|
|
|
'filename' => [ |
|
67
|
|
|
'label' => 'Filename', |
|
68
|
|
|
'helptext' => 'The original filename of the document' |
|
69
|
|
|
], |
|
70
|
|
|
'mime' => [ |
|
71
|
|
|
'label' => 'Mimetype', |
|
72
|
|
|
'helptext' => 'The mime type of the file' |
|
73
|
|
|
], |
|
74
|
|
|
'size' => [ |
|
75
|
|
|
'label' => 'File Size', |
|
76
|
|
|
'helptext' => 'The size of the file in bytes' |
|
77
|
|
|
], |
|
78
|
|
|
'uploaded_by_id' => [ |
|
79
|
|
|
'label' => 'User ID', |
|
80
|
|
|
'helptext' => 'ID of the user who uploaded the file' |
|
81
|
|
|
], |
|
82
|
|
|
'uploaded_by_email' => [ |
|
83
|
|
|
'label' => 'User Email', |
|
84
|
|
|
'helptext' => 'Email of the user who uploaded the file' |
|
85
|
|
|
], |
|
86
|
|
|
'uploaded_by_first_name' => [ |
|
87
|
|
|
'label' => 'User First Name', |
|
88
|
|
|
'helptext' => 'First Name of the user who uploaded the file' |
|
89
|
|
|
], |
|
90
|
|
|
'uploaded_by_last_name' => [ |
|
91
|
|
|
'label' => 'User Last Name', |
|
92
|
|
|
'helptext' => 'Last Name of the user who uploaded the file' |
|
93
|
|
|
], |
|
94
|
|
|
'uploaded_by_preferred_name' => [ |
|
95
|
|
|
'label' => 'User Preferred Name', |
|
96
|
|
|
'helptext' => 'Preferred Name of the user who uploaded the file' |
|
97
|
|
|
], |
|
98
|
|
|
'module_instance_id' => [ |
|
99
|
|
|
'label' => 'Module Instance ID', |
|
100
|
|
|
'helptext' => 'ID of the module instance the file was uploaded to' |
|
101
|
|
|
], |
|
102
|
|
|
'activity_instance_id' => [ |
|
103
|
|
|
'label' => 'Activity Instance ID', |
|
104
|
|
|
'helptext' => 'ID of the activity instance that uploaded the file' |
|
105
|
|
|
], |
|
106
|
|
|
'uploaded_at' => [ |
|
107
|
|
|
'label' => 'Uploaded At', |
|
108
|
|
|
'helptext' => 'Time and date the file was uploaded at' |
|
109
|
|
|
], |
|
110
|
|
|
'updated_at' => [ |
|
111
|
|
|
'label' => 'Updated At', |
|
112
|
|
|
'helptext' => 'Time and date the file was last updated' |
|
113
|
|
|
], |
|
114
|
|
|
'status' => [ |
|
115
|
|
|
'label' => 'Status', |
|
116
|
|
|
'helptext' => 'Status of the file' |
|
117
|
|
|
] |
|
118
|
|
|
]; |
|
119
|
|
|
} |
|
120
|
|
|
} |