File events refactoring
This commit is contained in:
@@ -70,13 +70,8 @@ class NotificationJob extends BaseJob
|
||||
$values['subtask'] = $this->subtaskModel->getById($event['id'], true);
|
||||
$values['task'] = $this->taskFinderModel->getDetails($values['subtask']['task_id']);
|
||||
break;
|
||||
case 'Kanboard\Event\FileEvent':
|
||||
$values['file'] = $event;
|
||||
$values['task'] = $this->taskFinderModel->getDetails($values['file']['task_id']);
|
||||
break;
|
||||
case 'Kanboard\Event\CommentEvent':
|
||||
default:
|
||||
$values = $event;
|
||||
break;
|
||||
}
|
||||
|
||||
return $values;
|
||||
|
||||
45
app/Job/ProjectFileEventJob.php
Normal file
45
app/Job/ProjectFileEventJob.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Job;
|
||||
|
||||
use Kanboard\EventBuilder\ProjectFileEventBuilder;
|
||||
|
||||
/**
|
||||
* Class ProjectFileEventJob
|
||||
*
|
||||
* @package Kanboard\Job
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class ProjectFileEventJob extends BaseJob
|
||||
{
|
||||
/**
|
||||
* Set job params
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $eventName
|
||||
* @return $this
|
||||
*/
|
||||
public function withParams($fileId, $eventName)
|
||||
{
|
||||
$this->jobParams = array($fileId, $eventName);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute job
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $eventName
|
||||
* @return $this
|
||||
*/
|
||||
public function execute($fileId, $eventName)
|
||||
{
|
||||
$event = ProjectFileEventBuilder::getInstance($this->container)
|
||||
->withFileId($fileId)
|
||||
->build();
|
||||
|
||||
if ($event !== null) {
|
||||
$this->dispatcher->dispatch($eventName, $event);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
app/Job/TaskFileEventJob.php
Normal file
45
app/Job/TaskFileEventJob.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Job;
|
||||
|
||||
use Kanboard\EventBuilder\TaskFileEventBuilder;
|
||||
|
||||
/**
|
||||
* Class TaskFileEventJob
|
||||
*
|
||||
* @package Kanboard\Job
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class TaskFileEventJob extends BaseJob
|
||||
{
|
||||
/**
|
||||
* Set job params
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $eventName
|
||||
* @return $this
|
||||
*/
|
||||
public function withParams($fileId, $eventName)
|
||||
{
|
||||
$this->jobParams = array($fileId, $eventName);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute job
|
||||
*
|
||||
* @param int $fileId
|
||||
* @param string $eventName
|
||||
* @return $this
|
||||
*/
|
||||
public function execute($fileId, $eventName)
|
||||
{
|
||||
$event = TaskFileEventBuilder::getInstance($this->container)
|
||||
->withFileId($fileId)
|
||||
->build();
|
||||
|
||||
if ($event !== null) {
|
||||
$this->dispatcher->dispatch($eventName, $event);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user