|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Blackmine\Model\Issue; |
|
6
|
|
|
|
|
7
|
|
|
use Blackmine\Collection\RepeatableIdCollection; |
|
8
|
|
|
use Blackmine\Model\CustomField; |
|
9
|
|
|
use Blackmine\Model\Enumeration\IssuePriority; |
|
10
|
|
|
use Blackmine\Model\Project\Version; |
|
11
|
|
|
use Blackmine\Mutator\MutableInterface; |
|
12
|
|
|
use Blackmine\Mutator\Mutation\RemoveKeyMutation; |
|
13
|
|
|
use Blackmine\Mutator\Mutation\RenameKeyMutation; |
|
14
|
|
|
use Carbon\CarbonImmutable; |
|
15
|
|
|
use Blackmine\Collection\IdentityCollection; |
|
16
|
|
|
use Blackmine\Model\FetchableInterface; |
|
17
|
|
|
use Blackmine\Model\NamedIdentity; |
|
18
|
|
|
use Blackmine\Model\User\User; |
|
19
|
|
|
use Blackmine\Model\Project\IssueCategory; |
|
20
|
|
|
use Blackmine\Model\Project\Project; |
|
21
|
|
|
use Blackmine\Model\Project\Tracker; |
|
22
|
|
|
use Blackmine\Repository\Issues\Issues; |
|
23
|
|
|
use Blackmine\Model\Identity; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @method void setProject(Project $project) |
|
27
|
|
|
* @method void setTracker(Tracker $tracker) |
|
28
|
|
|
* @method void setStatus (Status $status) |
|
29
|
|
|
* @method void setPriority(NamedIdentity $priority) |
|
30
|
|
|
* @method void setAuthor(User $author) |
|
31
|
|
|
* @method void setAssignedTo(User $user) |
|
32
|
|
|
* @method void setCategory(IssueCategory $category) |
|
33
|
|
|
* @method void setFixedVersion(Version $version) |
|
34
|
|
|
* @method void setSubject(string $subject) |
|
35
|
|
|
* @method void setDescription(string $description) |
|
36
|
|
|
* @method void setStartDate(CarbonImmutable $start_date) |
|
37
|
|
|
* @method void setDueDate(CarbonImmutable $due_date) |
|
38
|
|
|
* @method void setDoneRatio(float $done_ratio) |
|
39
|
|
|
* @method void setEstimatedHours(float $estimated_hours) |
|
40
|
|
|
* @method void setSpentHours(float $spent_hours) |
|
41
|
|
|
* @method void setNotes(string $notes) |
|
42
|
|
|
* @method void setPrivateNotes(bool $private_notes) |
|
43
|
|
|
* @method void setParentIssue(Issue $parent_issue) |
|
44
|
|
|
* @method void setIsPrivate(bool $is_private) |
|
45
|
|
|
* |
|
46
|
|
|
* @method Project getProject() |
|
47
|
|
|
* @method Tracker getTracker() |
|
48
|
|
|
* @method Status getStatus() |
|
49
|
|
|
* @method NamedIdentity getPriority() |
|
50
|
|
|
* @method User getAuthor() |
|
51
|
|
|
* @method User getAssignedTo() |
|
52
|
|
|
* @method IssueCategory getCategory() |
|
53
|
|
|
* @method Version getFixedVersion() |
|
54
|
|
|
* @method string getSubject() |
|
55
|
|
|
* @method string getDescription() |
|
56
|
|
|
* @method CarbonImmutable getStartDate() |
|
57
|
|
|
* @method CarbonImmutable getDueDate() |
|
58
|
|
|
* @method float getDoneRatio() |
|
59
|
|
|
* @method float getEstimatedHours() |
|
60
|
|
|
* @method float getTotalEstimatedHours() |
|
61
|
|
|
* @method float getSpentHours() |
|
62
|
|
|
* @method float getTotalSpentHours() |
|
63
|
|
|
* @method Issue getParentIssue() |
|
64
|
|
|
* @method IdentityCollection getCustomFields() |
|
65
|
|
|
* @method IdentityCollection getRelations() |
|
66
|
|
|
* @method IdentityCollection getChildren() |
|
67
|
|
|
* @method IdentityCollection getAttachments() |
|
68
|
|
|
* @method IdentityCollection getJournals() |
|
69
|
|
|
* @method IdentityCollection getChangesets() |
|
70
|
|
|
* @method RepeatableIdCollection getWatchers() |
|
71
|
|
|
* @method CarbonImmutable getCreatedOn() |
|
72
|
|
|
* @method CarbonImmutable getUpdatedOn() |
|
73
|
|
|
* @method CarbonImmutable getClosedOn() |
|
74
|
|
|
* |
|
75
|
|
|
* @method bool isPrivate() |
|
76
|
|
|
* |
|
77
|
|
|
* @method void addWatcher(User $watcher) |
|
78
|
|
|
* @method void removeWatcher(User $watcher) |
|
79
|
|
|
* @method void addAttachment(Attachment $attachment) |
|
80
|
|
|
* @method void removeAttachment(Attachment $attachment) |
|
81
|
|
|
* @method void addChild(Issue $child); |
|
82
|
|
|
* @method void removeChild(Issue $child) |
|
83
|
|
|
* @method void addCustomField(CustomField $custom_field) |
|
84
|
|
|
* @method void removeCustomField(CustomField $customField) |
|
85
|
|
|
*/ |
|
86
|
|
|
class Issue extends Identity implements FetchableInterface, MutableInterface |
|
87
|
|
|
{ |
|
88
|
|
|
public const ENTITY_NAME = "issue"; |
|
89
|
|
|
|
|
90
|
|
|
protected Project $project; |
|
91
|
|
|
protected Tracker $tracker; |
|
92
|
|
|
protected Status $status; |
|
93
|
|
|
protected IssuePriority $priority; |
|
94
|
|
|
protected User $author; |
|
95
|
|
|
protected ?User $assigned_to; |
|
96
|
|
|
protected IssueCategory $category; |
|
97
|
|
|
protected Version $fixed_version; |
|
98
|
|
|
protected string $subject; |
|
99
|
|
|
protected string $description; |
|
100
|
|
|
protected bool $is_private; |
|
101
|
|
|
protected CarbonImmutable $start_date; |
|
102
|
|
|
protected CarbonImmutable $due_date; |
|
103
|
|
|
|
|
104
|
|
|
protected float $done_ratio; |
|
105
|
|
|
protected float $estimated_hours; |
|
106
|
|
|
protected float $total_estimated_hours; |
|
107
|
|
|
protected float $spent_hours; |
|
108
|
|
|
protected float $total_spent_hours; |
|
109
|
|
|
|
|
110
|
|
|
protected ?string $notes = null; |
|
111
|
|
|
protected bool $private_notes; |
|
112
|
|
|
|
|
113
|
|
|
protected ?Issue $parent_issue = null; |
|
114
|
|
|
|
|
115
|
|
|
protected IdentityCollection $custom_fields; |
|
116
|
|
|
protected IdentityCollection $relations; |
|
117
|
|
|
protected IdentityCollection $children; |
|
118
|
|
|
protected IdentityCollection $attachments; |
|
119
|
|
|
protected IdentityCollection $journals; |
|
120
|
|
|
protected IdentityCollection $changesets; |
|
121
|
|
|
protected RepeatableIdCollection $watchers; |
|
122
|
|
|
|
|
123
|
|
|
protected CarbonImmutable $created_on; |
|
124
|
|
|
protected ?CarbonImmutable $updated_on; |
|
125
|
|
|
protected ?CarbonImmutable $closed_on; |
|
126
|
|
|
|
|
127
|
|
|
|
|
128
|
|
|
public function __construct(protected ?int $id = null) |
|
129
|
|
|
{ |
|
130
|
|
|
$this->custom_fields = new IdentityCollection(); |
|
131
|
|
|
$this->relations = new IdentityCollection(); |
|
132
|
|
|
$this->children = new IdentityCollection(); |
|
133
|
|
|
$this->attachments = new IdentityCollection(); |
|
134
|
|
|
$this->journals = new IdentityCollection(); |
|
135
|
|
|
$this->changesets = new IdentityCollection(); |
|
136
|
|
|
$this->watchers = new RepeatableIdCollection(); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
public function comment(string $notes): void |
|
140
|
|
|
{ |
|
141
|
|
|
$this->notes = $notes; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
public static function getRepositoryClass(): ?string |
|
145
|
|
|
{ |
|
146
|
|
|
return Issues::class; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
public function getMutations(): array |
|
150
|
|
|
{ |
|
151
|
|
|
return [ |
|
152
|
|
|
"parent_issue" => [RenameKeyMutation::class => ["parent_issue_id"]], |
|
153
|
|
|
"watchers" => [RenameKeyMutation::class => ["watcher_user_ids"]], |
|
154
|
|
|
"attachments" => [RenameKeyMutation::class => ["uploads"]], |
|
155
|
|
|
"created_on" => [RemoveKeyMutation::class => []], |
|
156
|
|
|
"updated_on" => [RemoveKeyMutation::class => []], |
|
157
|
|
|
"closed_on" => [RemoveKeyMutation::class => []], |
|
158
|
|
|
"changesets" => [RemoveKeyMutation::class => []], |
|
159
|
|
|
"relations" => [RemoveKeyMutation::class => []], |
|
160
|
|
|
"journals" => [RemoveKeyMutation::class => []], |
|
161
|
|
|
"children" => [RemoveKeyMutation::class => []], |
|
162
|
|
|
]; |
|
163
|
|
|
} |
|
164
|
|
|
} |
|
165
|
|
|
|