Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/xaction/DifferentialRevisionAbandonTransaction.php
12256 views
1
<?php
2
3
final class DifferentialRevisionAbandonTransaction
4
extends DifferentialRevisionActionTransaction {
5
6
const TRANSACTIONTYPE = 'differential.revision.abandon';
7
const ACTIONKEY = 'abandon';
8
9
protected function getRevisionActionLabel(
10
DifferentialRevision $revision,
11
PhabricatorUser $viewer) {
12
return pht('Abandon Revision');
13
}
14
15
protected function getRevisionActionDescription(
16
DifferentialRevision $revision,
17
PhabricatorUser $viewer) {
18
return pht('This revision will be abandoned and closed.');
19
}
20
21
public function getIcon() {
22
return 'fa-plane';
23
}
24
25
public function getColor() {
26
return 'indigo';
27
}
28
29
protected function getRevisionActionOrder() {
30
return 500;
31
}
32
33
public function getActionName() {
34
return pht('Abandoned');
35
}
36
37
public function getCommandKeyword() {
38
return 'abandon';
39
}
40
41
public function getCommandAliases() {
42
return array();
43
}
44
45
public function getCommandSummary() {
46
return pht('Abandon a revision.');
47
}
48
49
public function generateOldValue($object) {
50
return $object->isAbandoned();
51
}
52
53
public function applyInternalEffects($object, $value) {
54
$status_abandoned = DifferentialRevisionStatus::ABANDONED;
55
$object->setModernRevisionStatus($status_abandoned);
56
}
57
58
protected function validateAction($object, PhabricatorUser $viewer) {
59
if ($object->isClosed()) {
60
throw new Exception(
61
pht(
62
'You can not abandon this revision because it has already been '.
63
'closed. Only open revisions can be abandoned.'));
64
}
65
66
$config_key = 'differential.always-allow-abandon';
67
if (!PhabricatorEnv::getEnvConfig($config_key)) {
68
if (!$this->isViewerRevisionAuthor($object, $viewer)) {
69
throw new Exception(
70
pht(
71
'You can not abandon this revision because you are not the '.
72
'author. You can only abandon revisions you own. You can change '.
73
'this behavior by adjusting the "%s" setting in Config.',
74
$config_key));
75
}
76
}
77
}
78
79
public function getTitle() {
80
return pht(
81
'%s abandoned this revision.',
82
$this->renderAuthor());
83
}
84
85
public function getTitleForFeed() {
86
return pht(
87
'%s abandoned %s.',
88
$this->renderAuthor(),
89
$this->renderObject());
90
}
91
92
public function getTransactionTypeForConduit($xaction) {
93
return 'abandon';
94
}
95
96
public function getFieldValuesForConduit($object, $data) {
97
return array();
98
}
99
100
}
101
102