refactor: leverage Task and TaskManager external api methods to create task
refactor: remove uneeded configuration
This commit is contained in:
112
src/TaskwarriorManager.php
Normal file
112
src/TaskwarriorManager.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace Aerex\TaskwarriorPlugin;
|
||||
|
||||
use Aerex\TaskwarriorPlugin\Taskwarrior;
|
||||
use DavidBadura\Taskwarrior\TaskManager;
|
||||
use DavidBadura\Taskwarrior\Task;
|
||||
|
||||
class TaskwarriorManager extends TaskManager {
|
||||
|
||||
const DESCRIPTION = 'description';
|
||||
const CATEGORIES = 'categories';
|
||||
const TASK_UUID = 'uuid';
|
||||
const ICAL_UID = 'uid';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \DavidBadura\Taskwarrior\Task
|
||||
*/
|
||||
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();
|
||||
$this->setValue($task, $ICAL_UID, $UUID);
|
||||
return $task;
|
||||
}
|
||||
|
||||
public function export(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
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){}
|
||||
function setDueDate($dueDate){}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user