Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/xaction/DifferentialRevisionRejectTransaction.php
12256 views
1
<?php
2
3
final class DifferentialRevisionRejectTransaction
4
extends DifferentialRevisionReviewTransaction {
5
6
const TRANSACTIONTYPE = 'differential.revision.reject';
7
const ACTIONKEY = 'reject';
8
9
protected function getRevisionActionLabel(
10
DifferentialRevision $revision,
11
PhabricatorUser $viewer) {
12
return pht('Request Changes');
13
}
14
15
protected function getRevisionActionDescription(
16
DifferentialRevision $revision,
17
PhabricatorUser $viewer) {
18
return pht('This revision will be returned to the author for updates.');
19
}
20
21
public function getIcon() {
22
return 'fa-times-circle-o';
23
}
24
25
public function getColor() {
26
return 'red';
27
}
28
29
protected function getRevisionActionOrder() {
30
return 600;
31
}
32
33
public function getActionName() {
34
return pht('Requested Changes');
35
}
36
37
public function getCommandKeyword() {
38
return 'request';
39
}
40
41
public function getCommandAliases() {
42
return array(
43
'reject',
44
);
45
}
46
47
public function getCommandSummary() {
48
return pht('Request changes to a revision.');
49
}
50
51
public function generateOldValue($object) {
52
$actor = $this->getActor();
53
return $this->isViewerFullyRejected($object, $actor);
54
}
55
56
public function applyExternalEffects($object, $value) {
57
$status = DifferentialReviewerStatus::STATUS_REJECTED;
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 request changes to this revision because it has '.
67
'already been closed. You can only request changes to open '.
68
'revisions.'));
69
}
70
71
if ($this->isViewerRevisionAuthor($object, $viewer)) {
72
throw new Exception(
73
pht(
74
'You can not request changes to this revision because you are the '.
75
'revision author. You can only request changes to revisions you do '.
76
'not own.'));
77
}
78
79
if ($object->isDraft() || !$object->getShouldBroadcast()) {
80
throw new Exception(
81
pht('You can not request changes to a draft revision.'));
82
}
83
84
if ($this->isViewerFullyRejected($object, $viewer)) {
85
throw new Exception(
86
pht(
87
'You can not request changes to this revision because you have '.
88
'already requested changes.'));
89
}
90
}
91
92
public function getTitle() {
93
return pht(
94
'%s requested changes to this revision.',
95
$this->renderAuthor());
96
}
97
98
public function getTitleForFeed() {
99
return pht(
100
'%s requested changes to %s.',
101
$this->renderAuthor(),
102
$this->renderObject());
103
}
104
105
public function getTransactionTypeForConduit($xaction) {
106
return 'request-changes';
107
}
108
109
public function getFieldValuesForConduit($object, $data) {
110
return array();
111
}
112
113
}
114
115