Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/harbormaster/xaction/build/HarbormasterBuildMessageResumeTransaction.php
12264 views
1
<?php
2
3
final class HarbormasterBuildMessageResumeTransaction
4
extends HarbormasterBuildMessageTransaction {
5
6
const TRANSACTIONTYPE = 'message/resume';
7
const MESSAGETYPE = 'resume';
8
9
public function getHarbormasterBuildMessageName() {
10
return pht('Resume Build');
11
}
12
13
public function getHarbormasterBuildableMessageName() {
14
return pht('Resume Builds');
15
}
16
17
public function getHarbormasterBuildableMessageEffect() {
18
return pht('Build will resume.');
19
}
20
21
public function newConfirmPromptTitle() {
22
return pht('Really resume build?');
23
}
24
25
public function newConfirmPromptBody() {
26
return pht(
27
'Work will continue on the build. Really resume?');
28
}
29
30
public function getHarbormasterBuildMessageDescription() {
31
return pht('Resume work on a previously paused build.');
32
}
33
34
public function newBuildableConfirmPromptTitle(
35
array $builds,
36
array $sendable) {
37
return pht(
38
'Really resume %s build(s)?',
39
phutil_count($builds));
40
}
41
42
public function newBuildableConfirmPromptBody(
43
array $builds,
44
array $sendable) {
45
46
if (count($sendable) === count($builds)) {
47
return pht(
48
'Work will continue on all builds. Really resume?');
49
} else {
50
return pht(
51
'You can only resume some builds. Work will continue on builds '.
52
'you have permission to resume.');
53
}
54
}
55
56
public function getTitle() {
57
return pht(
58
'%s resumed this build.',
59
$this->renderAuthor());
60
}
61
62
public function getIcon() {
63
return 'fa-play';
64
}
65
66
public function applyInternalEffects($object, $value) {
67
$actor = $this->getActor();
68
$build = $object;
69
70
$build->setBuildStatus(HarbormasterBuildStatus::STATUS_BUILDING);
71
}
72
73
protected function newCanApplyMessageAssertion(
74
PhabricatorUser $viewer,
75
HarbormasterBuild $build) {
76
77
if ($build->isAutobuild()) {
78
throw new HarbormasterMessageException(
79
pht('Unable to Resume Build'),
80
pht(
81
'You can not resume a build that uses an autoplan.'));
82
}
83
84
if (!$build->isPaused() && !$build->isPausing()) {
85
throw new HarbormasterMessageException(
86
pht('Unable to Resume Build'),
87
pht(
88
'You can not resume this build because it is not paused. You can '.
89
'only resume a paused build.'));
90
}
91
92
}
93
94
protected function newCanSendMessageAssertion(
95
PhabricatorUser $viewer,
96
HarbormasterBuild $build) {
97
98
if ($build->isResuming()) {
99
throw new HarbormasterMessageException(
100
pht('Unable to Resume Build'),
101
pht(
102
'You can not resume this build beacuse it is already resuming.'));
103
}
104
105
if ($build->isRestarting()) {
106
throw new HarbormasterMessageException(
107
pht('Unable to Resume Build'),
108
pht('You can not resume this build because it is already restarting.'));
109
}
110
111
if ($build->isAborting()) {
112
throw new HarbormasterMessageException(
113
pht('Unable to Resume Build'),
114
pht('You can not resume this build because it is already aborting.'));
115
}
116
117
}
118
119
}
120
121