Add new event subtask.create_update
This commit is contained in:
parent
1f6a42ace7
commit
490bcd17d8
|
|
@ -3,6 +3,7 @@
|
|||
namespace Kanboard\Core\Event;
|
||||
|
||||
use Kanboard\Model\TaskModel;
|
||||
use Kanboard\Model\SubtaskModel;
|
||||
use Kanboard\Model\TaskLinkModel;
|
||||
|
||||
/**
|
||||
|
|
@ -54,6 +55,7 @@ class EventManager
|
|||
TaskModel::EVENT_ASSIGNEE_CHANGE => t('Task assignee change'),
|
||||
TaskModel::EVENT_DAILY_CRONJOB => t('Daily background job for tasks'),
|
||||
TaskModel::EVENT_MOVE_SWIMLANE => t('Move a task to another swimlane'),
|
||||
SubtaskModel::EVENT_CREATE_UPDATE => t('Subtask creation or modification'),
|
||||
);
|
||||
|
||||
$events = array_merge($events, $this->events);
|
||||
|
|
|
|||
|
|
@ -15,25 +15,25 @@ class SubtaskEventJob extends BaseJob
|
|||
/**
|
||||
* Set job params
|
||||
*
|
||||
* @param int $subtaskId
|
||||
* @param string $eventName
|
||||
* @param array $values
|
||||
* @param int $subtaskId
|
||||
* @param array $eventNames
|
||||
* @param array $values
|
||||
* @return $this
|
||||
*/
|
||||
public function withParams($subtaskId, $eventName, array $values = array())
|
||||
public function withParams($subtaskId, array $eventNames, array $values = array())
|
||||
{
|
||||
$this->jobParams = array($subtaskId, $eventName, $values);
|
||||
$this->jobParams = array($subtaskId, $eventNames, $values);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute job
|
||||
*
|
||||
* @param int $subtaskId
|
||||
* @param string $eventName
|
||||
* @param array $values
|
||||
* @param int $subtaskId
|
||||
* @param array $eventNames
|
||||
* @param array $values
|
||||
*/
|
||||
public function execute($subtaskId, $eventName, array $values = array())
|
||||
public function execute($subtaskId, array $eventNames, array $values = array())
|
||||
{
|
||||
$event = SubtaskEventBuilder::getInstance($this->container)
|
||||
->withSubtaskId($subtaskId)
|
||||
|
|
@ -41,7 +41,9 @@ class SubtaskEventJob extends BaseJob
|
|||
->buildEvent();
|
||||
|
||||
if ($event !== null) {
|
||||
$this->dispatcher->dispatch($eventName, $event);
|
||||
foreach ($eventNames as $eventName) {
|
||||
$this->dispatcher->dispatch($eventName, $event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1409,14 +1409,16 @@ return array(
|
|||
'XBT - bitcoin' => 'XBT - Bitcoin',
|
||||
'Assigned' => 'Zugeordnet',
|
||||
'Task limits apply to each swimlane individually' => 'Aufgabenlimit gilt pro Swimlane',
|
||||
// 'Column task limits apply to each swimlane individually' => '',
|
||||
// 'Column task limits are applied to each swimlane individually' => '',
|
||||
// 'Column task limits are applied across swimlanes' => '',
|
||||
// 'Task limit: ' => '',
|
||||
'Column task limits apply to each swimlane individually' => 'Spaltenaufgabenlimit für jede Swimlane einzeln anwenden',
|
||||
'Column task limits are applied to each swimlane individually' => 'Spaltenaufgabenlimit wird für jede Swimlane einzeln angewendet',
|
||||
'Column task limits are applied across swimlanes' => 'Spaltenaufgabenlimit wird swimlaneübergreifend angewendet',
|
||||
'Task limit: ' => 'Aufgabenlimit',
|
||||
'Change to global tag' => 'Zu globalem Schlagwort machen',
|
||||
'Do you really want to make the tag "%s" global?' => 'Das Schlagwort "%s" wirklich global machen?',
|
||||
'Enable global tags for this project' => 'Globale Schlagworte für dieses Projekt aktivieren',
|
||||
'Group membership(s):' => 'Gruppen-Mitgliedschaft(en):',
|
||||
'%s is a member of the following group(s): %s' => '%s ist Mitglied in der/den folgenden Gruppe(n): %s',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
'Group membership(s):' => 'Gruppen Mitgliedschaft(en)',
|
||||
'Subtask creation or modification' => 'Teilaufgabe erstellen oder ändern',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
'Group membership(s):' => 'Membre des groupes :',
|
||||
'%s is a member of the following group(s): %s' => '%s est membre des groupes suivants: %s',
|
||||
'%d/%d group(s) shown' => '%d/%d groupe(s) affiché(s)',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,7 @@ return array(
|
|||
'Group membership(s):' => 'Состоит в группах:',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Enable global tags for this project' => '',
|
||||
// 'Group membership(s):' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1419,4 +1419,5 @@ return array(
|
|||
// 'Group membership(s):' => '',
|
||||
// '%s is a member of the following group(s): %s' => '',
|
||||
// '%d/%d group(s) shown' => '',
|
||||
// 'Subtask creation or modification' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -34,9 +34,10 @@ class SubtaskModel extends Base
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
const EVENT_UPDATE = 'subtask.update';
|
||||
const EVENT_CREATE = 'subtask.create';
|
||||
const EVENT_DELETE = 'subtask.delete';
|
||||
const EVENT_UPDATE = 'subtask.update';
|
||||
const EVENT_CREATE = 'subtask.create';
|
||||
const EVENT_DELETE = 'subtask.delete';
|
||||
const EVENT_CREATE_UPDATE = 'subtask.create_update';
|
||||
|
||||
/**
|
||||
* Get projectId from subtaskId
|
||||
|
|
@ -216,7 +217,10 @@ class SubtaskModel extends Base
|
|||
|
||||
if ($subtaskId !== false) {
|
||||
$this->subtaskTimeTrackingModel->updateTaskTimeTracking($values['task_id']);
|
||||
$this->queueManager->push($this->subtaskEventJob->withParams($subtaskId, self::EVENT_CREATE));
|
||||
$this->queueManager->push($this->subtaskEventJob->withParams(
|
||||
$subtaskId,
|
||||
array(self::EVENT_CREATE_UPDATE, self::EVENT_CREATE)
|
||||
));
|
||||
}
|
||||
|
||||
return $subtaskId;
|
||||
|
|
@ -240,7 +244,11 @@ class SubtaskModel extends Base
|
|||
$this->subtaskTimeTrackingModel->updateTaskTimeTracking($subtask['task_id']);
|
||||
|
||||
if ($fireEvent) {
|
||||
$this->queueManager->push($this->subtaskEventJob->withParams($subtask['id'], self::EVENT_UPDATE, $values));
|
||||
$this->queueManager->push($this->subtaskEventJob->withParams(
|
||||
$subtask['id'],
|
||||
array(self::EVENT_CREATE_UPDATE, self::EVENT_UPDATE),
|
||||
$values
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -256,7 +264,7 @@ class SubtaskModel extends Base
|
|||
*/
|
||||
public function remove($subtaskId)
|
||||
{
|
||||
$this->subtaskEventJob->execute($subtaskId, self::EVENT_DELETE);
|
||||
$this->subtaskEventJob->execute($subtaskId, array(self::EVENT_DELETE));
|
||||
return $this->db->table(self::TABLE)->eq('id', $subtaskId)->remove();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ class SubtaskEventJobTest extends Base
|
|||
public function testJobParams()
|
||||
{
|
||||
$subtaskEventJob = new SubtaskEventJob($this->container);
|
||||
$subtaskEventJob->withParams(123, 'foobar', array('k' => 'v'));
|
||||
$subtaskEventJob->withParams(123, array('foobar'), array('k' => 'v'));
|
||||
|
||||
$this->assertSame(array(123, 'foobar', array('k' => 'v')), $subtaskEventJob->getJobParams());
|
||||
$this->assertSame(array(123, array('foobar'), array('k' => 'v')), $subtaskEventJob->getJobParams());
|
||||
}
|
||||
|
||||
public function testWithMissingSubtask()
|
||||
|
|
@ -22,7 +22,7 @@ class SubtaskEventJobTest extends Base
|
|||
$this->container['dispatcher']->addListener(SubtaskModel::EVENT_CREATE, function() {});
|
||||
|
||||
$subtaskEventJob = new SubtaskEventJob($this->container);
|
||||
$subtaskEventJob->execute(42, SubtaskModel::EVENT_CREATE);
|
||||
$subtaskEventJob->execute(42, array(SubtaskModel::EVENT_CREATE));
|
||||
|
||||
$called = $this->container['dispatcher']->getCalledListeners();
|
||||
$this->assertEmpty($called);
|
||||
|
|
@ -33,6 +33,7 @@ class SubtaskEventJobTest extends Base
|
|||
$this->container['dispatcher']->addListener(SubtaskModel::EVENT_CREATE, function() {});
|
||||
$this->container['dispatcher']->addListener(SubtaskModel::EVENT_UPDATE, function() {});
|
||||
$this->container['dispatcher']->addListener(SubtaskModel::EVENT_DELETE, function() {});
|
||||
$this->container['dispatcher']->addListener(SubtaskModel::EVENT_CREATE_UPDATE, function() {});
|
||||
|
||||
$subtaskModel = new SubtaskModel($this->container);
|
||||
$taskCreationModel = new TaskCreationModel($this->container);
|
||||
|
|
@ -48,5 +49,6 @@ class SubtaskEventJobTest extends Base
|
|||
$this->assertArrayHasKey(SubtaskModel::EVENT_CREATE.'.closure', $called);
|
||||
$this->assertArrayHasKey(SubtaskModel::EVENT_UPDATE.'.closure', $called);
|
||||
$this->assertArrayHasKey(SubtaskModel::EVENT_DELETE.'.closure', $called);
|
||||
$this->assertArrayHasKey(SubtaskModel::EVENT_CREATE_UPDATE.'.closure', $called);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue