Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/xaction/DiffusionCommitAcceptTransaction.php
12241 views
1
<?php
2
3
final class DiffusionCommitAcceptTransaction
4
extends DiffusionCommitAuditTransaction {
5
6
const TRANSACTIONTYPE = 'diffusion.commit.accept';
7
const ACTIONKEY = 'accept';
8
9
protected function getCommitActionLabel() {
10
return pht('Accept Commit');
11
}
12
13
protected function getCommitActionDescription() {
14
return pht('This commit will be approved.');
15
}
16
17
public function getIcon() {
18
return 'fa-check-circle-o';
19
}
20
21
public function getColor() {
22
return 'green';
23
}
24
25
protected function getCommitActionOrder() {
26
return 500;
27
}
28
29
public function getActionName() {
30
return pht('Accepted');
31
}
32
33
public function applyExternalEffects($object, $value) {
34
$status = PhabricatorAuditRequestStatus::ACCEPTED;
35
$actor = $this->getActor();
36
$this->applyAuditorEffect($object, $actor, $value, $status);
37
}
38
39
protected function validateAction($object, PhabricatorUser $viewer) {
40
$config_key = 'audit.can-author-close-audit';
41
if (!PhabricatorEnv::getEnvConfig($config_key)) {
42
if ($this->isViewerCommitAuthor($object, $viewer)) {
43
throw new Exception(
44
pht(
45
'You can not accept this commit because you are the commit '.
46
'author. You can only accept commits you did not author. You can '.
47
'change this behavior by adjusting the "%s" setting in Config.',
48
$config_key));
49
}
50
}
51
52
if ($this->isViewerFullyAccepted($object, $viewer)) {
53
throw new Exception(
54
pht(
55
'You can not accept this commit because you have already '.
56
'accepted it.'));
57
}
58
}
59
60
public function getTitle() {
61
return pht(
62
'%s accepted this commit.',
63
$this->renderAuthor());
64
}
65
66
public function getTitleForFeed() {
67
return pht(
68
'%s accepted %s.',
69
$this->renderAuthor(),
70
$this->renderObject());
71
}
72
73
public function getTransactionTypeForConduit($xaction) {
74
return 'accept';
75
}
76
77
public function getFieldValuesForConduit($object, $data) {
78
return array();
79
}
80
81
}
82
83