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