From d54350363bddbf222d4dc676414baccb71feacb2 Mon Sep 17 00:00:00 2001 From: Romain Tripault Date: Mon, 23 Jan 2023 13:41:29 +0100 Subject: [PATCH] Added new event when a file entry is saved (creation/update) --- _build/resolvers/resolve.customevents.php | 1 + .../model/mediamanager/classes/files.class.php | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/_build/resolvers/resolve.customevents.php b/_build/resolvers/resolve.customevents.php index 469ae56..70217b8 100644 --- a/_build/resolvers/resolve.customevents.php +++ b/_build/resolvers/resolve.customevents.php @@ -10,6 +10,7 @@ $events = [ 'MediaManagerFileArchived', 'MediaManagerFileDeleted', + 'MediaManagerFileSaved', 'MediaManagerFileVersionChanged', diff --git a/core/components/mediamanager/model/mediamanager/classes/files.class.php b/core/components/mediamanager/model/mediamanager/classes/files.class.php index 9aba1f0..b9bf455 100644 --- a/core/components/mediamanager/model/mediamanager/classes/files.class.php +++ b/core/components/mediamanager/model/mediamanager/classes/files.class.php @@ -1580,6 +1580,16 @@ public function saveFile($fileId, $rawData) } $file->save(); + $this->mediaManager->modx->invokeEvent( + 'MediaManagerFileSaved', + [ + 'file_id' => $fileId, + 'file' => $file, + 'created_new_version' => $createFileVersion, + 'version_number' => $file->get('version'), + ] + ); + return []; }