Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/xaction/DifferentialRevisionBuildableTransaction.php
12256 views
1
<?php
2
3
final class DifferentialRevisionBuildableTransaction
4
extends DifferentialRevisionTransactionType {
5
6
// NOTE: This uses an older constant for compatibility. We should perhaps
7
// migrate these at some point.
8
const TRANSACTIONTYPE = 'harbormaster:buildable';
9
10
public function generateNewValue($object, $value) {
11
return $value;
12
}
13
14
public function generateOldValue($object) {
15
return $object->getBuildableStatus($this->getBuildablePHID());
16
}
17
18
public function applyInternalEffects($object, $value) {
19
$object->setBuildableStatus($this->getBuildablePHID(), $value);
20
}
21
22
public function getIcon() {
23
return $this->newBuildableStatus()->getIcon();
24
}
25
26
public function getColor() {
27
return $this->newBuildableStatus()->getColor();
28
}
29
30
public function getActionName() {
31
return $this->newBuildableStatus()->getActionName();
32
}
33
34
public function shouldHideForFeed() {
35
return !$this->newBuildableStatus()->isFailed();
36
}
37
38
public function shouldHideForMail() {
39
return !$this->newBuildableStatus()->isFailed();
40
}
41
42
public function getTitle() {
43
$new = $this->getNewValue();
44
$buildable_phid = $this->getBuildablePHID();
45
46
switch ($new) {
47
case HarbormasterBuildableStatus::STATUS_PASSED:
48
return pht(
49
'%s completed remote builds in %s.',
50
$this->renderAuthor(),
51
$this->renderHandle($buildable_phid));
52
case HarbormasterBuildableStatus::STATUS_FAILED:
53
return pht(
54
'%s failed remote builds in %s!',
55
$this->renderAuthor(),
56
$this->renderHandle($buildable_phid));
57
}
58
59
return null;
60
}
61
62
public function getTitleForFeed() {
63
$new = $this->getNewValue();
64
$buildable_phid = $this->getBuildablePHID();
65
66
switch ($new) {
67
case HarbormasterBuildableStatus::STATUS_PASSED:
68
return pht(
69
'%s completed remote builds in %s for %s.',
70
$this->renderAuthor(),
71
$this->renderHandle($buildable_phid),
72
$this->renderObject());
73
case HarbormasterBuildableStatus::STATUS_FAILED:
74
return pht(
75
'%s failed remote builds in %s for %s!',
76
$this->renderAuthor(),
77
$this->renderHandle($buildable_phid),
78
$this->renderObject());
79
}
80
81
return null;
82
}
83
84
private function newBuildableStatus() {
85
$new = $this->getNewValue();
86
return HarbormasterBuildableStatus::newBuildableStatusObject($new);
87
}
88
89
private function getBuildablePHID() {
90
return $this->getMetadataValue('harbormaster:buildablePHID');
91
}
92
93
}
94
95