Add subtasks restrictions and time tracking

This commit is contained in:
Frederic Guillot
2015-02-04 22:19:32 -05:00
parent 2d070627d7
commit b24b1e7e4e
38 changed files with 522 additions and 51 deletions

View File

@@ -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']);
}
}
}
}