add start&stop
This commit is contained in:
parent
f4ba78f822
commit
9f3ea62916
25
src/Task.php
25
src/Task.php
@ -84,6 +84,13 @@ class Task
|
||||
*/
|
||||
private $entry;
|
||||
|
||||
/**
|
||||
* @var Carbon
|
||||
*
|
||||
* @JMS\Type("Carbon")
|
||||
*/
|
||||
private $start;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
@ -186,7 +193,7 @@ class Task
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getDue()
|
||||
{
|
||||
@ -202,7 +209,7 @@ class Task
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getWait()
|
||||
{
|
||||
@ -284,7 +291,7 @@ class Task
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getUntil()
|
||||
{
|
||||
@ -300,7 +307,7 @@ class Task
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getEntry()
|
||||
{
|
||||
@ -308,7 +315,15 @@ class Task
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getStart()
|
||||
{
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Carbon
|
||||
*/
|
||||
public function getModified()
|
||||
{
|
||||
|
@ -155,6 +155,32 @@ class TaskManager
|
||||
$this->refresh($task);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Task $task
|
||||
*/
|
||||
public function start(Task $task)
|
||||
{
|
||||
if (!$task->getUuid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->taskwarrior->start($task->getUuid());
|
||||
$this->refresh($task);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Task $task
|
||||
*/
|
||||
public function stop(Task $task)
|
||||
{
|
||||
if (!$task->getUuid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->taskwarrior->stop($task->getUuid());
|
||||
$this->refresh($task);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Task $task
|
||||
*/
|
||||
@ -313,6 +339,7 @@ class TaskManager
|
||||
$this->setValue($old, 'urgency', $new->getUrgency());
|
||||
$this->setValue($old, 'status', $new->getStatus());
|
||||
$this->setValue($old, 'modified', $new->getModified());
|
||||
$this->setValue($old, 'start', $new->getStart());
|
||||
|
||||
if ($new->isPending()) { // fix reopen problem
|
||||
$this->setValue($old, 'end', null);
|
||||
|
@ -62,6 +62,22 @@ class Taskwarrior
|
||||
$this->command('done', $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filter
|
||||
*/
|
||||
public function start($filter)
|
||||
{
|
||||
$this->command('start', $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filter
|
||||
*/
|
||||
public function stop($filter)
|
||||
{
|
||||
$this->command('stop', $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
*/
|
||||
|
@ -270,6 +270,26 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertInstanceOf('DateTime', $task1->getEnd());
|
||||
}
|
||||
|
||||
public function testStart()
|
||||
{
|
||||
$task1 = new Task();
|
||||
$task1->setDescription('foo1');
|
||||
|
||||
$this->taskManager->save($task1);
|
||||
|
||||
$this->assertNull($task1->getStart());
|
||||
|
||||
$this->taskManager->start($task1);
|
||||
$this->taskManager->save($task1);
|
||||
|
||||
$this->assertInstanceOf('DateTime', $task1->getStart());
|
||||
|
||||
$this->taskManager->stop($task1);
|
||||
$this->taskManager->save($task1);
|
||||
|
||||
$this->assertNull($task1->getStart());
|
||||
}
|
||||
|
||||
public function testPending()
|
||||
{
|
||||
$task1 = new Task();
|
||||
|
Loading…
Reference in New Issue
Block a user