|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Helix\Asana\User; |
|
4
|
|
|
|
|
5
|
|
|
use ArrayIterator; |
|
6
|
|
|
use Helix\Asana\Base\AbstractEntity; |
|
7
|
|
|
use Helix\Asana\Task; |
|
8
|
|
|
use Helix\Asana\User; |
|
9
|
|
|
use Helix\Asana\Workspace; |
|
10
|
|
|
use IteratorAggregate; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* A user's task list in a given workspace. |
|
14
|
|
|
* |
|
15
|
|
|
* @see https://developers.asana.com/docs/asana-user-task-lists |
|
16
|
|
|
* @see https://developers.asana.com/docs/user-task-list |
|
17
|
|
|
* |
|
18
|
|
|
* @immutable User task lists are read-only through the API. |
|
19
|
|
|
* |
|
20
|
|
|
* @method string getName () |
|
21
|
|
|
* @method User getOwner () |
|
22
|
|
|
* @method Workspace getWorkspace () |
|
23
|
|
|
*/ |
|
24
|
|
|
class TaskList extends AbstractEntity implements IteratorAggregate { |
|
25
|
|
|
|
|
26
|
|
|
const TYPE = 'user_task_list'; |
|
27
|
|
|
|
|
28
|
|
|
protected static $map = [ |
|
29
|
|
|
'owner' => User::class, |
|
30
|
|
|
'workspace' => Workspace::class |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
final public function __toString (): string { |
|
34
|
|
|
return "user_task_lists/{$this->getGid()}"; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function getCacheKeys () { |
|
38
|
|
|
$keys = parent::getCacheKeys(); |
|
39
|
|
|
|
|
40
|
|
|
/** @see User::getTaskList() */ |
|
41
|
|
|
if (isset($this->data['owner'], $this->data['workspace'])) { |
|
42
|
|
|
$keys[] = "{$this->getOwner()}/user_task_list?workspace={$this->getWorkspace()->getGid()}"; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
return $keys; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @return Task[] |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getIncompleteTasks () { |
|
52
|
|
|
return $this->getTasks(['completed_since' => 'now']); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Returns an iterator for all tasks. |
|
57
|
|
|
* |
|
58
|
|
|
* @return ArrayIterator|Task[] |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getIterator () { |
|
61
|
|
|
return new ArrayIterator($this->getTasks()); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* The user's tasks, regardless of workspace. |
|
66
|
|
|
* |
|
67
|
|
|
* @see https://developers.asana.com/docs/get-tasks-from-a-user-task-list |
|
68
|
|
|
* |
|
69
|
|
|
* @param array $filter |
|
70
|
|
|
* @return Task[] |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getTasks (array $filter = []) { |
|
73
|
|
|
return $this->loadAll(Task::class, "{$this}/tasks", $filter); |
|
74
|
|
|
} |
|
75
|
|
|
} |