diff --git a/src/Exception/ReferenceException.php b/src/Exception/ReferenceException.php index ed6f36a..a72e981 100644 --- a/src/Exception/ReferenceException.php +++ b/src/Exception/ReferenceException.php @@ -1,12 +1,10 @@ + */ class ReferenceException extends TaskwarriorException { - -} \ No newline at end of file +} diff --git a/src/Serializer/Handler/DependsHandler.php b/src/Serializer/Handler/DependsHandler.php index 997c026..fbda42d 100644 --- a/src/Serializer/Handler/DependsHandler.php +++ b/src/Serializer/Handler/DependsHandler.php @@ -40,14 +40,14 @@ class DependsHandler implements SubscribingHandlerInterface 'type' => 'Depends', 'format' => 'json', 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION, - 'method' => 'deserializeCarbon' + 'method' => 'deserialize' ); $methods[] = array( 'type' => 'Depends', 'format' => 'json', 'direction' => GraphNavigator::DIRECTION_SERIALIZATION, - 'method' => 'serializeCarbon' + 'method' => 'serialize' ); return $methods; @@ -61,7 +61,7 @@ class DependsHandler implements SubscribingHandlerInterface * @return string * @throws ReferenceException */ - public function serializeCarbon(VisitorInterface $visitor, $tasks, array $type, Context $context) + public function serialize(VisitorInterface $visitor, $tasks, array $type, Context $context) { $list = []; @@ -82,10 +82,8 @@ class DependsHandler implements SubscribingHandlerInterface * @param array $type * @return ArrayCollection */ - public function deserializeCarbon(VisitorInterface $visitor, $data, array $type) + public function deserialize(VisitorInterface $visitor, $data, array $type) { - dump($data); - if (!$data) { return new ArrayCollection(); } diff --git a/src/Task.php b/src/Task.php index c95a92f..adcc979 100644 --- a/src/Task.php +++ b/src/Task.php @@ -301,6 +301,18 @@ class Task $this->depends->removeElement($task); } + /** + * @param Task[] $tasks + */ + public function setDependencies(array $tasks) + { + $this->depends = new ArrayCollection(); + + foreach ($tasks as $task) { + $this->addDependency($task); + } + } + /** * @return Recurring */ @@ -462,4 +474,4 @@ class Task $this->entry = new Carbon('now'); $this->status = self::STATUS_PENDING; } -} \ No newline at end of file +} diff --git a/src/TaskManager.php b/src/TaskManager.php index 31ff42c..e0b798c 100644 --- a/src/TaskManager.php +++ b/src/TaskManager.php @@ -340,7 +340,17 @@ class TaskManager { $json = $this->taskwarrior->export($filter); - return $this->getSerializer()->deserialize($json, 'array', 'json'); + $tasks = $this->getSerializer()->deserialize($json, 'array', 'json'); + + foreach ($tasks as $task) { + if ($task->getDependencies()) { + continue; + } + + $task->setDependencies(array()); + } + + return $tasks; } /** @@ -482,4 +492,4 @@ class TaskManager { return new self(new Taskwarrior()); } -} \ No newline at end of file +} diff --git a/tests/TaskManagerTest.php b/tests/TaskManagerTest.php index 4e17610..6955328 100644 --- a/tests/TaskManagerTest.php +++ b/tests/TaskManagerTest.php @@ -837,8 +837,6 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase $this->taskManager->clear(); $temp1 = $this->taskManager->find($task1->getUuid()); - dump($temp1); - $this->assertCount(0, $temp1->getDependencies()); } @@ -850,4 +848,4 @@ class TaskManagerTest extends \PHPUnit_Framework_TestCase { return new \Carbon\Carbon($string); } -} \ No newline at end of file +}