|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Helix\Asana\Project; |
|
4
|
|
|
|
|
5
|
|
|
use Helix\Asana\Base\AbstractEntity; |
|
6
|
|
|
use Helix\Asana\Base\AbstractEntity\CreateTrait; |
|
7
|
|
|
use Helix\Asana\Base\AbstractEntity\DeleteTrait; |
|
8
|
|
|
use Helix\Asana\Project; |
|
9
|
|
|
use Helix\Asana\User; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* A project status. |
|
13
|
|
|
* |
|
14
|
|
|
* @see https://developers.asana.com/docs/asana-project-statuses |
|
15
|
|
|
* @see https://developers.asana.com/docs/project-status |
|
16
|
|
|
* |
|
17
|
|
|
* @immutable Statuses may only be deleted after creation. |
|
18
|
|
|
* |
|
19
|
|
|
* @method string getColor () |
|
20
|
|
|
* @method $this setColor (string $color) @depends create-only |
|
21
|
|
|
* @method string getCreatedAt () |
|
22
|
|
|
* @method User getCreatedBy () |
|
23
|
|
|
* @method string getText () |
|
24
|
|
|
* @method $this setText (string $text) @depends create-only |
|
25
|
|
|
* @method string getTitle () |
|
26
|
|
|
*/ |
|
27
|
|
|
class Status extends AbstractEntity { |
|
28
|
|
|
|
|
29
|
|
|
use CreateTrait; |
|
30
|
|
|
use DeleteTrait; |
|
31
|
|
|
|
|
32
|
|
|
const TYPE = 'project_status'; |
|
33
|
|
|
|
|
34
|
|
|
const COLOR_GREEN = 'green'; |
|
35
|
|
|
const COLOR_RED = 'red'; |
|
36
|
|
|
const COLOR_YELLOW = 'yellow'; |
|
37
|
|
|
|
|
38
|
|
|
protected static $map = [ |
|
39
|
|
|
'created_by' => User::class |
|
40
|
|
|
]; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var Project |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $project; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Remote doesn't have a `project` property, so it's required here. |
|
49
|
|
|
* |
|
50
|
|
|
* @param Project $project |
|
51
|
|
|
* @param array $data |
|
52
|
|
|
*/ |
|
53
|
|
|
public function __construct (Project $project, array $data = []) { |
|
54
|
|
|
parent::__construct($project, $data); |
|
55
|
|
|
$this->project = $project; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
final public function __toString (): string { |
|
59
|
|
|
return "project_statuses/{$this->getGid()}"; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
final protected function _getDir (): string { |
|
63
|
|
|
return "{$this->project}/project_statuses"; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
protected function _setData (array $data): void { |
|
67
|
|
|
// redundant, prefer created_by |
|
68
|
|
|
unset($data['author']); |
|
69
|
|
|
parent::_setData($data); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @return Project |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getProject () { |
|
76
|
|
|
return $this->project; |
|
77
|
|
|
} |
|
78
|
|
|
} |