Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/xaction/DiffusionCommitBuildableTransaction.php
12241 views
1
<?php
2
3
final class DiffusionCommitBuildableTransaction
4
extends DiffusionCommitTransactionType {
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 null;
16
}
17
18
public function getIcon() {
19
return $this->newBuildableStatus()->getIcon();
20
}
21
22
public function getColor() {
23
return $this->newBuildableStatus()->getColor();
24
}
25
26
public function getActionName() {
27
return $this->newBuildableStatus()->getActionName();
28
}
29
30
public function shouldHideForFeed() {
31
return !$this->newBuildableStatus()->isFailed();
32
}
33
34
public function shouldHideForMail() {
35
return !$this->newBuildableStatus()->isFailed();
36
}
37
38
public function getTitle() {
39
$new = $this->getNewValue();
40
$buildable_phid = $this->getBuildablePHID();
41
42
switch ($new) {
43
case HarbormasterBuildableStatus::STATUS_PASSED:
44
return pht(
45
'%s completed building %s.',
46
$this->renderAuthor(),
47
$this->renderHandle($buildable_phid));
48
case HarbormasterBuildableStatus::STATUS_FAILED:
49
return pht(
50
'%s failed to build %s!',
51
$this->renderAuthor(),
52
$this->renderHandle($buildable_phid));
53
}
54
55
return null;
56
}
57
58
public function getTitleForFeed() {
59
$new = $this->getNewValue();
60
$buildable_phid = $this->getBuildablePHID();
61
62
switch ($new) {
63
case HarbormasterBuildableStatus::STATUS_PASSED:
64
return pht(
65
'%s completed building %s for %s.',
66
$this->renderAuthor(),
67
$this->renderHandle($buildable_phid),
68
$this->renderObject());
69
case HarbormasterBuildableStatus::STATUS_FAILED:
70
return pht(
71
'%s failed to build %s for %s!',
72
$this->renderAuthor(),
73
$this->renderHandle($buildable_phid),
74
$this->renderObject());
75
}
76
77
return null;
78
}
79
80
private function newBuildableStatus() {
81
$new = $this->getNewValue();
82
return HarbormasterBuildableStatus::newBuildableStatusObject($new);
83
}
84
85
private function getBuildablePHID() {
86
return $this->getMetadataValue('harbormaster:buildablePHID');
87
}
88
89
}
90
91