Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/xaction/DifferentialRevisionResignTransaction.php
12256 views
1
<?php
2
3
final class DifferentialRevisionResignTransaction
4
extends DifferentialRevisionReviewTransaction {
5
6
const TRANSACTIONTYPE = 'differential.revision.resign';
7
const ACTIONKEY = 'resign';
8
9
protected function getRevisionActionLabel(
10
DifferentialRevision $revision,
11
PhabricatorUser $viewer) {
12
return pht('Resign as Reviewer');
13
}
14
15
protected function getRevisionActionDescription(
16
DifferentialRevision $revision,
17
PhabricatorUser $viewer) {
18
return pht('You will resign as a reviewer for this change.');
19
}
20
21
public function getIcon() {
22
return 'fa-flag';
23
}
24
25
public function getColor() {
26
return 'orange';
27
}
28
29
protected function getRevisionActionOrder() {
30
return 700;
31
}
32
33
public function getCommandKeyword() {
34
return 'resign';
35
}
36
37
public function getActionName() {
38
return pht('Resigned');
39
}
40
41
public function getCommandAliases() {
42
return array();
43
}
44
45
public function getCommandSummary() {
46
return pht('Resign from a revision.');
47
}
48
49
public function generateOldValue($object) {
50
$actor = $this->getActor();
51
$resigned = DifferentialReviewerStatus::STATUS_RESIGNED;
52
53
return ($this->getViewerReviewerStatus($object, $actor) == $resigned);
54
}
55
56
public function applyExternalEffects($object, $value) {
57
$status = DifferentialReviewerStatus::STATUS_RESIGNED;
58
$actor = $this->getActor();
59
$this->applyReviewerEffect($object, $actor, $value, $status);
60
}
61
62
protected function validateAction($object, PhabricatorUser $viewer) {
63
if ($object->isClosed()) {
64
throw new Exception(
65
pht(
66
'You can not resign from this revision because it has already '.
67
'been closed. You can only resign from open revisions.'));
68
}
69
70
$resigned = DifferentialReviewerStatus::STATUS_RESIGNED;
71
if ($this->getViewerReviewerStatus($object, $viewer) == $resigned) {
72
throw new Exception(
73
pht(
74
'You can not resign from this revision because you have already '.
75
'resigned.'));
76
}
77
78
if (!$this->isViewerAnyAuthority($object, $viewer)) {
79
throw new Exception(
80
pht(
81
'You can not resign from this revision because you are not a '.
82
'reviewer, and do not have authority over any reviewer.'));
83
}
84
}
85
86
public function getTitle() {
87
return pht(
88
'%s resigned from this revision.',
89
$this->renderAuthor());
90
}
91
92
public function getTitleForFeed() {
93
return pht(
94
'%s resigned from %s.',
95
$this->renderAuthor(),
96
$this->renderObject());
97
}
98
99
public function getTransactionTypeForConduit($xaction) {
100
return 'resign';
101
}
102
103
public function getFieldValuesForConduit($object, $data) {
104
return array();
105
}
106
107
}
108
109