Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/config/module/PhabricatorConfigCollectorsModule.php
12262 views
1
<?php
2
3
final class PhabricatorConfigCollectorsModule extends PhabricatorConfigModule {
4
5
public function getModuleKey() {
6
return 'collectors';
7
}
8
9
public function getModuleName() {
10
return pht('Garbage Collectors');
11
}
12
13
public function renderModuleStatus(AphrontRequest $request) {
14
$viewer = $request->getViewer();
15
16
$collectors = PhabricatorGarbageCollector::getAllCollectors();
17
$collectors = msort($collectors, 'getCollectorConstant');
18
19
$rows = array();
20
$rowc = array();
21
foreach ($collectors as $key => $collector) {
22
$class = null;
23
if ($collector->hasAutomaticPolicy()) {
24
$policy_view = phutil_tag('em', array(), pht('Automatic'));
25
} else {
26
$policy = $collector->getRetentionPolicy();
27
if ($policy === null) {
28
$policy_view = pht('Indefinite');
29
} else {
30
$days = ceil($policy / phutil_units('1 day in seconds'));
31
$policy_view = pht(
32
'%s Day(s)',
33
new PhutilNumber($days));
34
}
35
36
$default = $collector->getDefaultRetentionPolicy();
37
if ($policy !== $default) {
38
$class = 'highlighted';
39
$policy_view = phutil_tag('strong', array(), $policy_view);
40
}
41
}
42
43
$rowc[] = $class;
44
$rows[] = array(
45
$collector->getCollectorConstant(),
46
$collector->getCollectorName(),
47
$policy_view,
48
);
49
}
50
51
$info = id(new PHUIInfoView())
52
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
53
->appendChild(pht(
54
'Collectors with custom policies are highlighted. Use '.
55
'%s to change retention policies.',
56
phutil_tag('tt', array(), 'bin/garbage set-policy')));
57
58
$table = id(new AphrontTableView($rows))
59
->setNotice($info)
60
->setRowClasses($rowc)
61
->setHeaders(
62
array(
63
pht('Constant'),
64
pht('Name'),
65
pht('Retention Policy'),
66
))
67
->setColumnClasses(
68
array(
69
null,
70
'pri wide',
71
null,
72
));
73
74
return $table;
75
}
76
77
}
78
79