Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/console/plugin/DarkConsoleEventPlugin.php
13402 views
1
<?php
2
3
final class DarkConsoleEventPlugin extends DarkConsolePlugin {
4
5
public function getName() {
6
return pht('Events');
7
}
8
9
public function getDescription() {
10
return pht('Information about events and event listeners.');
11
}
12
13
public function generateData() {
14
$listeners = PhutilEventEngine::getInstance()->getAllListeners();
15
foreach ($listeners as $key => $listener) {
16
$listeners[$key] = array(
17
'id' => $listener->getListenerID(),
18
'class' => get_class($listener),
19
);
20
}
21
22
$events = DarkConsoleEventPluginAPI::getEvents();
23
foreach ($events as $key => $event) {
24
$events[$key] = array(
25
'type' => $event->getType(),
26
'stopped' => $event->isStopped(),
27
);
28
}
29
30
return array(
31
'listeners' => $listeners,
32
'events' => $events,
33
);
34
}
35
36
public function renderPanel() {
37
$data = $this->getData();
38
39
$out = array();
40
41
$out[] = phutil_tag(
42
'div',
43
array('class' => 'dark-console-panel-header'),
44
phutil_tag('h1', array(), pht('Registered Event Listeners')));
45
46
$rows = array();
47
foreach ($data['listeners'] as $listener) {
48
$rows[] = array($listener['id'], $listener['class']);
49
}
50
51
$table = new AphrontTableView($rows);
52
$table->setHeaders(
53
array(
54
pht('Internal ID'),
55
pht('Listener Class'),
56
));
57
$table->setColumnClasses(
58
array(
59
'',
60
'wide',
61
));
62
63
$out[] = $table->render();
64
65
$out[] = phutil_tag(
66
'div',
67
array('class' => 'dark-console-panel-header'),
68
phutil_tag('h1', array(), pht('Event Log')));
69
70
$rows = array();
71
foreach ($data['events'] as $event) {
72
$rows[] = array(
73
$event['type'],
74
$event['stopped'] ? pht('STOPPED') : null,
75
);
76
}
77
78
$table = new AphrontTableView($rows);
79
$table->setColumnClasses(
80
array(
81
'wide',
82
));
83
$table->setHeaders(
84
array(
85
pht('Event Type'),
86
pht('Stopped'),
87
));
88
89
$out[] = $table->render();
90
91
92
return phutil_implode_html("\n", $out);
93
}
94
95
}
96
97