[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/console/plugin/ -> DarkConsoleEventPlugin.php (source)

   1  <?php
   2  
   3  final class DarkConsoleEventPlugin extends DarkConsolePlugin {
   4  
   5    public function getName() {
   6      return 'Events';
   7    }
   8  
   9    public function getDescription() {
  10      return 'Information about Phabricator 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          'Internal ID',
  55          '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'] ? 'STOPPED' : null,
  75        );
  76      }
  77  
  78      $table = new AphrontTableView($rows);
  79      $table->setColumnClasses(
  80        array(
  81          'wide',
  82        ));
  83      $table->setHeaders(
  84        array(
  85          'Event Type',
  86          'Stopped',
  87        ));
  88  
  89      $out[] = $table->render();
  90  
  91  
  92      return phutil_implode_html("\n", $out);
  93    }
  94  
  95  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1