| 1 | <?php |
||
| 3 | class CreatorLastEditorExtension extends DataExtension |
||
|
|
|||
| 4 | { |
||
| 5 | private static $has_one = array( |
||
| 6 | 'Creator' => 'Member', |
||
| 7 | 'LastEditor' => 'Member', |
||
| 8 | ); |
||
| 9 | |||
| 10 | /* |
||
| 11 | 1) Save the creator as the current editing member if there is not creator already assigned |
||
| 12 | 2) Save the last editor (e.g. an admin) as the person who last edited this document |
||
| 13 | */ |
||
| 14 | public function onBeforeWrite() |
||
| 21 | |||
| 22 | /* |
||
| 23 | Allow the admin to override the creator and last editor |
||
| 24 | */ |
||
| 25 | public function updateCMSFields(FieldList $fields) |
||
| 34 | } |
||
| 35 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.