Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/xaction/DifferentialRevisionCommandeerTransaction.php
12256 views
1
<?php
2
3
final class DifferentialRevisionCommandeerTransaction
4
extends DifferentialRevisionActionTransaction {
5
6
const TRANSACTIONTYPE = 'differential.revision.commandeer';
7
const ACTIONKEY = 'commandeer';
8
9
protected function getRevisionActionLabel(
10
DifferentialRevision $revision,
11
PhabricatorUser $viewer) {
12
return pht('Commandeer Revision');
13
}
14
15
protected function getRevisionActionDescription(
16
DifferentialRevision $revision,
17
PhabricatorUser $viewer) {
18
return pht('You will take control of this revision and become its author.');
19
}
20
21
public function getIcon() {
22
return 'fa-flag';
23
}
24
25
public function getColor() {
26
return 'sky';
27
}
28
29
protected function getRevisionActionOrder() {
30
return 700;
31
}
32
33
public function getActionName() {
34
return pht('Commandeered');
35
}
36
37
public function getCommandKeyword() {
38
return 'commandeer';
39
}
40
41
public function getCommandAliases() {
42
return array(
43
'claim',
44
);
45
}
46
47
public function getCommandSummary() {
48
return pht('Commandeer a revision.');
49
}
50
51
public function generateOldValue($object) {
52
return $object->getAuthorPHID();
53
}
54
55
public function generateNewValue($object, $value) {
56
$actor = $this->getActor();
57
return $actor->getPHID();
58
}
59
60
public function applyInternalEffects($object, $value) {
61
$object->setAuthorPHID($value);
62
}
63
64
protected function validateAction($object, PhabricatorUser $viewer) {
65
// If a revision has already landed, we generally want to discourage
66
// reopening and reusing it since this tends to create a big mess (users
67
// should create a new revision instead). Thus, we stop you from
68
// commandeering closed revisions.
69
70
// See PHI985. If the revision was abandoned, there's no peril in allowing
71
// the commandeer since the change (likely) never actually landed. So
72
// it's okay to commandeer abandoned revisions.
73
74
if ($object->isClosed() && !$object->isAbandoned()) {
75
throw new Exception(
76
pht(
77
'You can not commandeer this revision because it has already '.
78
'been closed. You can only commandeer open or abandoned '.
79
'revisions.'));
80
}
81
82
if ($this->isViewerRevisionAuthor($object, $viewer)) {
83
throw new Exception(
84
pht(
85
'You can not commandeer this revision because you are already '.
86
'the author.'));
87
}
88
}
89
90
public function getTitle() {
91
return pht(
92
'%s commandeered this revision.',
93
$this->renderAuthor());
94
}
95
96
public function getTitleForFeed() {
97
return pht(
98
'%s commandeered %s.',
99
$this->renderAuthor(),
100
$this->renderObject());
101
}
102
103
public function getTransactionTypeForConduit($xaction) {
104
return 'commandeer';
105
}
106
107
public function getFieldValuesForConduit($object, $data) {
108
return array();
109
}
110
111
}
112
113