diff options
Diffstat (limited to 'app/Subscriber')
-rw-r--r-- | app/Subscriber/SubtaskTimesheetSubscriber.php | 32 |
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']); + } + } + } +} |