summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
authorMichael <michaelvickers.uk@gmail.com>2018-10-16 01:39:42 +0100
committerfguillot <fred@kanboard.net>2018-10-15 17:39:42 -0700
commitcc81f9d4f5a9857e024829613ad670bc51056be5 (patch)
treeff27bfd8ce38eb174e1598f90e60077dbeb39466 /app/Model
parent00228ac12fedaf436869289c7c114dc6f76dd14c (diff)
Write log entry on file removal
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/FileModel.php11
-rw-r--r--app/Model/ProjectFileModel.php12
-rw-r--r--app/Model/TaskFileModel.php12
3 files changed, 35 insertions, 0 deletions
diff --git a/app/Model/FileModel.php b/app/Model/FileModel.php
index d04b03bf..1519cfaf 100644
--- a/app/Model/FileModel.php
+++ b/app/Model/FileModel.php
@@ -52,6 +52,15 @@ abstract class FileModel extends Base
abstract protected function fireCreationEvent($file_id);
/**
+ * Fire file destruction event
+ *
+ * @abstract
+ * @access protected
+ * @param integer $file_id
+ */
+ abstract protected function fireDestructionEvent($file_id);
+
+ /**
* Get PicoDb query to get all files
*
* @access protected
@@ -187,6 +196,8 @@ abstract class FileModel extends Base
public function remove($file_id)
{
try {
+ $this->fireDestructionEvent($file_id);
+
$file = $this->getById($file_id);
$this->objectStorage->remove($file['path']);
diff --git a/app/Model/ProjectFileModel.php b/app/Model/ProjectFileModel.php
index 4de4d66d..7da5741c 100644
--- a/app/Model/ProjectFileModel.php
+++ b/app/Model/ProjectFileModel.php
@@ -23,6 +23,7 @@ class ProjectFileModel extends FileModel
* @var string
*/
const EVENT_CREATE = 'project.file.create';
+ const EVENT_DESTROY = 'project.file.destroy';
/**
* Get the table
@@ -70,4 +71,15 @@ class ProjectFileModel extends FileModel
{
$this->queueManager->push($this->projectFileEventJob->withParams($file_id, self::EVENT_CREATE));
}
+
+ /**
+ * Fire file destruction event
+ *
+ * @access protected
+ * @param integer $file_id
+ */
+ protected function fireDestructionEvent($file_id)
+ {
+ $this->queueManager->push($this->projectFileEventJob->withParams($file_id, self::EVENT_DESTROY));
+ }
}
diff --git a/app/Model/TaskFileModel.php b/app/Model/TaskFileModel.php
index 0163da28..9d446004 100644
--- a/app/Model/TaskFileModel.php
+++ b/app/Model/TaskFileModel.php
@@ -23,6 +23,7 @@ class TaskFileModel extends FileModel
* @var string
*/
const EVENT_CREATE = 'task.file.create';
+ const EVENT_DESTROY = 'task.file.destroy';
/**
* Get the table
@@ -100,4 +101,15 @@ class TaskFileModel extends FileModel
{
$this->queueManager->push($this->taskFileEventJob->withParams($file_id, self::EVENT_CREATE));
}
+
+ /**
+ * Fire file destruction event
+ *
+ * @access protected
+ * @param integer $file_id
+ */
+ protected function fireDestructionEvent($file_id)
+ {
+ $this->queueManager->push($this->taskFileEventJob->withParams($file_id, self::EVENT_DESTROY));
+ }
}