summaryrefslogtreecommitdiff
path: root/app/Subscriber
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-02-04 22:19:32 -0500
committerFrederic Guillot <fred@kanboard.net>2015-02-04 22:19:32 -0500
commitb24b1e7e4e5ee0551ee56aa0f21c4425b479db2e (patch)
tree5fffaeb461707dada9f2909101d51c9da3c77a50 /app/Subscriber
parent2d070627d751bf5728ec98a5efaf163532594cd9 (diff)
Add subtasks restrictions and time tracking
Diffstat (limited to 'app/Subscriber')
-rw-r--r--app/Subscriber/SubtaskTimesheetSubscriber.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/Subscriber/SubtaskTimesheetSubscriber.php b/app/Subscriber/SubtaskTimesheetSubscriber.php
new file mode 100644
index 00000000..687db80a
--- /dev/null
+++ b/app/Subscriber/SubtaskTimesheetSubscriber.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Subscriber;
+
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Model\SubTask;
+use Event\SubtaskEvent;
+
+class SubtaskTimesheetSubscriber extends Base implements EventSubscriberInterface
+{
+ public static function getSubscribedEvents()
+ {
+ return array(
+ SubTask::EVENT_UPDATE => array('log', 0),
+ );
+ }
+
+ public function log(SubtaskEvent $event)
+ {
+ if (isset($event['status'])) {
+
+ $subtask = $this->subTask->getById($event['id']);
+
+ if ($subtask['status'] == SubTask::STATUS_INPROGRESS) {
+ $this->subtaskTimeTracking->logStartTime($subtask['id'], $subtask['user_id']);
+ }
+ else {
+ $this->subtaskTimeTracking->logEndTime($subtask['id'], $subtask['user_id']);
+ }
+ }
+ }
+}