Total Complexity | 5 |
Total Lines | 25 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | class EditorTrackingExtension extends DataExtension |
||
20 | { |
||
21 | private static $has_one = [ |
||
|
|||
22 | "CreatedBy" => Member::class, |
||
23 | "LastEditedBy" => Member::class, |
||
24 | ]; |
||
25 | |||
26 | public function onBeforeWrite() |
||
27 | { |
||
28 | $user = Security::getCurrentUser(); |
||
29 | if (!$this->owner->ID) { |
||
30 | $this->owner->CreatedBy = $user->ID ?? 0; |
||
31 | } |
||
32 | $this->owner->LastEditedBy = $user->ID ?? 0; |
||
33 | } |
||
34 | |||
35 | public function updateCMSFields(FieldList $fields) |
||
44 | } |
||
45 | } |
||
47 |