diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-02-11 21:05:23 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-02-11 21:05:23 -0500 |
commit | 1a8ca671b5a58dcdf45ed8c165d49e5dd5a2e9a6 (patch) | |
tree | f2d1ae2f5c590a2558eec58436589dcc326f48f2 /app | |
parent | 7f820a52b07de25296609eabf46e49acb424eeba (diff) |
Add subscriber for task (moved date)
Diffstat (limited to 'app')
-rw-r--r-- | app/Model/TaskPosition.php | 4 | ||||
-rw-r--r-- | app/ServiceProvider/EventDispatcherProvider.php | 2 | ||||
-rw-r--r-- | app/Subscriber/TaskMovedDateSubscriber.php | 24 |
3 files changed, 26 insertions, 4 deletions
diff --git a/app/Model/TaskPosition.php b/app/Model/TaskPosition.php index b8d9d7bf..1e49543a 100644 --- a/app/Model/TaskPosition.php +++ b/app/Model/TaskPosition.php @@ -31,10 +31,6 @@ class TaskPosition extends Base if ($result) { - if ($original_task['column_id'] != $column_id) { - $this->db->table(Task::TABLE)->eq('id', $task_id)->update(array('date_moved' => time())); - } - if ($original_task['swimlane_id'] != $swimlane_id) { $this->calculateAndSave($project_id, 0, $column_id, 1, $original_task['swimlane_id']); } diff --git a/app/ServiceProvider/EventDispatcherProvider.php b/app/ServiceProvider/EventDispatcherProvider.php index f65a9dca..ec382206 100644 --- a/app/ServiceProvider/EventDispatcherProvider.php +++ b/app/ServiceProvider/EventDispatcherProvider.php @@ -13,6 +13,7 @@ use Subscriber\ProjectDailySummarySubscriber; use Subscriber\ProjectModificationDateSubscriber; use Subscriber\WebhookSubscriber; use Subscriber\SubtaskTimesheetSubscriber; +use Subscriber\TaskMovedDateSubscriber; class EventDispatcherProvider implements ServiceProviderInterface { @@ -27,6 +28,7 @@ class EventDispatcherProvider implements ServiceProviderInterface $container['dispatcher']->addSubscriber(new WebhookSubscriber($container)); $container['dispatcher']->addSubscriber(new NotificationSubscriber($container)); $container['dispatcher']->addSubscriber(new SubtaskTimesheetSubscriber($container)); + $container['dispatcher']->addSubscriber(new TaskMovedDateSubscriber($container)); // Automatic actions $container['action']->attachEvents(); diff --git a/app/Subscriber/TaskMovedDateSubscriber.php b/app/Subscriber/TaskMovedDateSubscriber.php new file mode 100644 index 00000000..0e36acfa --- /dev/null +++ b/app/Subscriber/TaskMovedDateSubscriber.php @@ -0,0 +1,24 @@ +<?php + +namespace Subscriber; + +use Event\TaskEvent; +use Model\Task; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +class TaskMovedDateSubscriber extends Base implements EventSubscriberInterface +{ + public static function getSubscribedEvents() + { + return array( + Task::EVENT_MOVE_COLUMN => array('execute', 0), + ); + } + + public function execute(TaskEvent $event) + { + if (isset($event['task_id'])) { + $this->container['db']->table(Task::TABLE)->eq('id', $event['task_id'])->update(array('date_moved' => time())); + } + } +} |