Write log entry on file removal
This commit is contained in:
@@ -51,6 +51,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
|
||||
*
|
||||
@@ -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']);
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user