2011-09-30 21:54:17 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group console
|
|
|
|
*/
|
2012-03-13 19:18:11 +01:00
|
|
|
final class DarkConsoleEventPlugin extends DarkConsolePlugin {
|
2011-09-30 21:54:17 +02:00
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
return 'Events';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription() {
|
|
|
|
return 'Information about Phabricator events and event listeners.';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function generateData() {
|
|
|
|
|
2011-11-10 02:23:33 +01:00
|
|
|
$listeners = PhutilEventEngine::getInstance()->getAllListeners();
|
2011-09-30 21:54:17 +02:00
|
|
|
foreach ($listeners as $key => $listener) {
|
|
|
|
$listeners[$key] = array(
|
|
|
|
'id' => $listener->getListenerID(),
|
|
|
|
'class' => get_class($listener),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$events = DarkConsoleEventPluginAPI::getEvents();
|
|
|
|
foreach ($events as $key => $event) {
|
|
|
|
$events[$key] = array(
|
|
|
|
'type' => $event->getType(),
|
|
|
|
'stopped' => $event->isStopped(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'listeners' => $listeners,
|
|
|
|
'events' => $events,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
$data = $this->getData();
|
|
|
|
|
|
|
|
$out = array();
|
|
|
|
|
|
|
|
$out[] =
|
|
|
|
'<div class="dark-console-panel-header">'.
|
|
|
|
'<h1>Registered Event Listeners</h1>'.
|
|
|
|
'</div>';
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($data['listeners'] as $listener) {
|
|
|
|
$rows[] = array(
|
|
|
|
phutil_escape_html($listener['id']),
|
|
|
|
phutil_escape_html($listener['class']),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = new AphrontTableView($rows);
|
|
|
|
$table->setHeaders(
|
|
|
|
array(
|
|
|
|
'Internal ID',
|
|
|
|
'Listener Class',
|
|
|
|
));
|
|
|
|
$table->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'',
|
|
|
|
'wide',
|
|
|
|
));
|
|
|
|
|
|
|
|
$out[] = $table->render();
|
|
|
|
|
|
|
|
$out[] =
|
|
|
|
'<div class="dark-console-panel-header">'.
|
|
|
|
'<h1>Event Log</h1>'.
|
|
|
|
'</div>';
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($data['events'] as $event) {
|
|
|
|
$rows[] = array(
|
|
|
|
phutil_escape_html($event['type']),
|
|
|
|
$event['stopped'] ? 'STOPPED' : null,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = new AphrontTableView($rows);
|
|
|
|
$table->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'wide',
|
|
|
|
));
|
|
|
|
$table->setHeaders(
|
|
|
|
array(
|
|
|
|
'Event Type',
|
|
|
|
'Stopped',
|
|
|
|
));
|
|
|
|
|
|
|
|
$out[] = $table->render();
|
|
|
|
|
|
|
|
|
|
|
|
return implode("\n", $out);
|
|
|
|
}
|
|
|
|
}
|