[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/infrastructure/events/ -> PhabricatorEventEngine.php (source)

   1  <?php
   2  
   3  final class PhabricatorEventEngine {
   4  
   5    public static function initialize() {
   6      // NOTE: If any of this fails, we just log it and move on. It's important
   7      // to try to make it through here because users may have difficulty fixing
   8      // fix the errors if we don't: for example, if we fatal here a user may not
   9      // be able to run `bin/config` in order to remove an invalid listener.
  10  
  11      // Load automatic listeners.
  12      $listeners = id(new PhutilSymbolLoader())
  13        ->setAncestorClass('PhabricatorAutoEventListener')
  14        ->loadObjects();
  15  
  16      // Load configured listeners.
  17      $config_listeners = PhabricatorEnv::getEnvConfig('events.listeners');
  18      foreach ($config_listeners as $listener_class) {
  19        try {
  20          $listeners[] = newv($listener_class, array());
  21        } catch (Exception $ex) {
  22          phlog($ex);
  23        }
  24      }
  25  
  26      // Add builtin listeners.
  27      $listeners[] = new DarkConsoleEventPluginAPI();
  28  
  29      // Add application listeners.
  30      $applications = PhabricatorApplication::getAllInstalledApplications();
  31      foreach ($applications as $application) {
  32        $app_listeners = $application->getEventListeners();
  33        foreach ($app_listeners as $listener) {
  34          $listener->setApplication($application);
  35          $listeners[] = $listener;
  36        }
  37      }
  38  
  39      // Now, register all of the listeners.
  40      foreach ($listeners as $listener) {
  41        try {
  42          $listener->register();
  43        } catch (Exception $ex) {
  44          phlog($ex);
  45        }
  46      }
  47    }
  48  
  49  }


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