davidbadura/taskwarrior

此软件包已被废弃且不再维护。未建议替代软件包。

php 库,用于 Taskwarrior

3.0.1 2016-07-13 07:39 UTC

README

doThings 使用 - Taskwarrior 的 web-ui。

Build Status

WOW

安装

composer require 'davidbadura/taskwarrior'

遗憾的是,在 composer 上没有自动注册注释读取器。因此,如果您遇到以下异常 [语义错误] 属性 [...] 中的注释 "@JMS\Serializer\Annotation\Type" 不存在或无法自动加载。,您应该添加以下行

\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists');

要求

Taskwarrior 通过补丁级别更新更改其行为,支持所有版本非常困难。当前支持的版本是

PHP 库 Taskwarrior PHP 版本
2.x >=2.4.3 >=5.4
3.x >=2.5.0 >=5.5

用法

use DavidBadura\Taskwarrior\TaskManager;
use DavidBadura\Taskwarrior\Task;
use DavidBadura\Taskwarrior\Recurring;
use DavidBadura\Taskwarrior\Annotation;

$tm = TaskManager::create();

$task = new Task();
$task->setDescription('program this lib');
$task->setProject('hobby');
$task->setDue('tomorrow');
$task->setPriority(Task::PRIORITY_HIGH);
$task->addTag('next');
$task->setRecurring(Recurring::DAILY);
$task->addAnnotation(new Annotation("and add many features"));

$tm->save($task);

$tasks = $tm->filterPending('project:hobby'); // one task

$tm->done($task);

$tasks = $tm->filterPending('project:hobby'); // empty
$tasks = $tm->filter('project:hobby'); // one task

$tasks = $tm->filterByReport('waiting'); // and sorting

API

任务

attr 可写 类型
uuid false 字符串
描述 true 字符串
优先级 true 字符串
项目 true 字符串
到期 true DateTime
等待 true DateTime
标签 true 字符串数组
注释 true 注释数组
紧急度 false 浮点数
条目 false DateTime
开始 false DateTime
重复 true 重复的
直到 true DateTime
修改 false DateTime
结束 false DateTime
状态 false 字符串

示例

$task = new Task();
$task->setDescription('program this lib');
$task->setProject('hobby');
$task->setDue('tomorrow');
$task->setPriority(Task::PRIORITY_HIGH);
$task->addTag('next');
$task->setRecurring(Recurring::DAILY);

Taskwarrior

创建任务管理器

$tm = TaskManager::create();

保存任务

$task = new Task();
$task->setDescription('foo');
$tm->save($task);

查找任务

$task = $tm->find('b1d46c75-63cc-4753-a20f-a0b376f1ead0');

过滤任务

$tasks = $tm->filter('status:pending');
$tasks = $tm->filter('status:pending +home');
$tasks = $tm->filter('status:pending and +home');
$tasks = $tm->filter(['status:pending', '+home']);

过滤待办任务

$tasks = $tm->filterPending('+home');
$tasks = $tm->filterPending('project:hobby +home');
$tasks = $tm->filterPending('project:hobby and +home');
$tasks = $tm->filterPending(['project:hobby', '+home']);

计算任务数量

$tasks = $tm->count('status:pending');
$tasks = $tm->count('status:pending +home');
$tasks = $tm->count('status:pending and +home');
$tasks = $tm->count(['status:pending', '+home']);

删除任务

$tm->delete($task);

完成任务

$tm->done($task);

开始任务

$tm->start($task);

停止任务

$tm->stop($task);

重新打开任务

$tm->reopen($task);

依赖关系

$task1 = new Task();
$task1->setDescription('a');

$task2 = new Task();
$task2->setDescription('b');

$task1->addDependency($task2);

// the order is important!
$tm->save($task2);
$tm->save($task1);

$tm->clear(); // clear object cache

$task1 = $tm->find('uuid-from-task1');
$task2 = $task1->getDependencies()[0];
echo $task2->getDesciption(); // "b" <- lazy loading

注释

$task = new Task();
$task->setDescription('a');
$task->addAnnotation(new Annotation("foobar"));

$tm->save($task);

$tm->clear(); // clear object cache

$task = $tm->find('uuid-from-task1');
$annotation = $task->getAnnotations()[0];
echo $annotation->getDesciption(); // "foobar"

QueryBuilder

示例

$tasks = $taskManager->createQueryBuilder()
    ->whereProject('hobby')
    ->orderBy(['entry' => 'DESC'])
    ->getResult()