add filterBy*
This commit is contained in:
parent
6268128cc9
commit
f4ba78f822
@ -36,6 +36,8 @@ $tasks = $tm->filter('project:hobby'); // one task
|
|||||||
$tm->done($task);
|
$tm->done($task);
|
||||||
|
|
||||||
$tasks = $tm->filter('project:hobby'); // empty
|
$tasks = $tm->filter('project:hobby'); // empty
|
||||||
|
|
||||||
|
$tasks = $tm->filterByReport('waiting');
|
||||||
```
|
```
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace DavidBadura\Taskwarrior;
|
namespace DavidBadura\Taskwarrior;
|
||||||
|
|
||||||
|
use DavidBadura\Taskwarrior\Config\Context;
|
||||||
|
use DavidBadura\Taskwarrior\Config\Report;
|
||||||
use DavidBadura\Taskwarrior\Exception\TaskwarriorException;
|
use DavidBadura\Taskwarrior\Exception\TaskwarriorException;
|
||||||
use DavidBadura\Taskwarrior\Query\QueryBuilder;
|
use DavidBadura\Taskwarrior\Query\QueryBuilder;
|
||||||
use DavidBadura\Taskwarrior\Serializer\Handler\CarbonHandler;
|
use DavidBadura\Taskwarrior\Serializer\Handler\CarbonHandler;
|
||||||
@ -221,6 +223,39 @@ class TaskManager
|
|||||||
return new QueryBuilder($this);
|
return new QueryBuilder($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Report|string $report
|
||||||
|
* @return Task[]|ArrayCollection
|
||||||
|
* @throws Exception\ConfigException
|
||||||
|
*/
|
||||||
|
public function filterByReport($report)
|
||||||
|
{
|
||||||
|
if (!$report instanceof Report) {
|
||||||
|
$report = $this->taskwarrior->config()->getReport($report);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->createQueryBuilder()
|
||||||
|
->where($report->filter)
|
||||||
|
->orderBy($report->sort)
|
||||||
|
->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Context|string $context
|
||||||
|
* @return Task[]|ArrayCollection
|
||||||
|
* @throws Exception\ConfigException
|
||||||
|
*/
|
||||||
|
public function filterByContext($context)
|
||||||
|
{
|
||||||
|
if (!$context instanceof Report) {
|
||||||
|
$context = $this->taskwarrior->config()->getContext($context);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->createQueryBuilder()
|
||||||
|
->where($context->filter)
|
||||||
|
->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|array $filter
|
* @param string|array $filter
|
||||||
* @return Task[]
|
* @return Task[]
|
||||||
|
Loading…
Reference in New Issue
Block a user