refactor: clean up code and remove some dependencies

This commit is contained in:
2018-11-25 17:35:33 -06:00
parent 2d2122e05d
commit 98b67855ca
19 changed files with 1075 additions and 565 deletions

View File

@@ -0,0 +1,158 @@
<?php
namespace Aerex\TaskwarriorPlugin;
use Aerex\TaskwarriorPlugin\Taskwarrior;
use Sabre\VObject\Component\VTodo;
use DavidBadura\Taskwarrior\TaskManager;
use DavidBadura\Taskwarrior\Task;
class TaskwarriorManager {
const DESCRIPTION = 'description';
const CATEGORIES = 'categories';
const TASK_UUID = 'uuid';
const ICAL_UID = 'uid';
private $tasks;
const ENTRY = 'entry';
const START = 'start';
const MODIFIED = 'modified';
const END = 'end';
public function __construct($taskwarrior){
parent::__construct($taskwarrior);
}
public function createTask($UUID){
$task = new Task();
}
public function export(VTodo $document){
}
public function addTask(VTodo $document){
$task = $this->taskwarrior->createTask($document->UID);
$task->setDescription($document);
$task->setEntry($document);
$task->setStartTime($document);
$task->setModifiedTime($document);
$task->setStopTime($document);
$task->setDue($document);
$task->setCategories($document);
$task->setStatus($document);
$task->setRecurrence($document);
return $this->taskwarrior->add($task);
}
public function updateTask(VTodo $document){
$task = $this->taskwarrior->get($document->UID);
$task->setDescription($document);
$task->setEntry($document);
$task->setStartTime($document);
$task->setModifiedTime($document);
$task->setStopTime($document);
$task->setDue($document);
$task->setCategories($document);
$task->setStatus($document);
$task->setRecurrence($document);
$updatedTask = $this->taskwarrior->modify($task);
return $upatedTask;
}
function setEntryTime($entry){
}
function exists($UUID){}
function setEndTime($end){}
function setModifiedTime($modifiedTime){}
function setSummary($description){
if(!isset($description)){
return;
}
$this->taskWarriorJSON[self::DESCRIPTION] = $description;
}
function setStartTime($startTime){}
function setCategories($categories){
if(!isset($categories)){
return;
}
if(!is_array($catergories)){
return;
}
$this->taskWarriorJSON[self::CATEGORIES] = $categories;
}
public function taskExists($taskUuid){
$taskIsInCache = isset($this->cachedTasks[$taskUuid]);
if($taskIsInCache){
return true;
}
$jsonArray = $this->taskwarrior->export($taskUuid);
$taskWithUuidExists = count($jsonArray) > 0;
return $taskWithUuidExists;
}
public function save(){
}
public function build(){
}
/**
* @param Task $task
* @param string $attr
* @param mixed $value
*/
public function setValue(Task $task, $attr, $value)
{
$refClass = new \ReflectionClass(Task::class);
$refProp = $refClass->getProperty($attr);
$refProp->setAccessible(true);
$refProp->setValue($task, $value);
}
function setDescription($description){}
function parseiCalDateTime($iCalDateTime){}
function convertToStringArray($categories){}
}
?>