Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/xaction/DifferentialRevisionHoldDraftTransaction.php
12256 views
1
<?php
2
3
final class DifferentialRevisionHoldDraftTransaction
4
extends DifferentialRevisionTransactionType {
5
6
const TRANSACTIONTYPE = 'draft';
7
const EDITKEY = 'draft';
8
9
public function generateOldValue($object) {
10
return (bool)$object->getHoldAsDraft();
11
}
12
13
public function generateNewValue($object, $value) {
14
return (bool)$value;
15
}
16
17
public function applyInternalEffects($object, $value) {
18
$object->setHoldAsDraft($value);
19
20
// If draft isn't the default state but we're creating a new revision
21
// and holding it as a draft, put it in draft mode. See PHI206.
22
// TODO: This can probably be removed once Draft is the universal default.
23
if ($this->isNewObject()) {
24
if ($object->isNeedsReview()) {
25
$object
26
->setModernRevisionStatus(DifferentialRevisionStatus::DRAFT)
27
->setShouldBroadcast(false);
28
}
29
}
30
}
31
32
public function getTitle() {
33
if ($this->getNewValue()) {
34
return pht(
35
'%s held this revision as a draft.',
36
$this->renderAuthor());
37
} else {
38
return pht(
39
'%s set this revision to automatically submit once builds complete.',
40
$this->renderAuthor());
41
}
42
}
43
44
public function getTitleForFeed() {
45
if ($this->getNewValue()) {
46
return pht(
47
'%s held %s as a draft.',
48
$this->renderAuthor(),
49
$this->renderObject());
50
} else {
51
return pht(
52
'%s set %s to automatically submit once builds complete.',
53
$this->renderAuthor(),
54
$this->renderObject());
55
}
56
}
57
58
public function getTransactionTypeForConduit($xaction) {
59
return 'draft';
60
}
61
62
public function getFieldValuesForConduit($xaction, $data) {
63
return array(
64
'old' => $xaction->getOldValue(),
65
'new' => $xaction->getNewValue(),
66
);
67
}
68
69
}
70
71