3 final class PhabricatorEventEngine
extends Phobject
{
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.
11 // Load automatic listeners.
12 $listeners = id(new PhutilClassMapQuery())
13 ->setAncestorClass('PhabricatorAutoEventListener')
16 // Load configured listeners.
17 $config_listeners = PhabricatorEnv
::getEnvConfig('events.listeners');
18 foreach ($config_listeners as $listener_class) {
20 $listeners[] = newv($listener_class, array());
21 } catch (Exception
$ex) {
26 // Add built-in listeners.
27 $listeners[] = new DarkConsoleEventPluginAPI();
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;
39 // Now, register all of the listeners.
40 foreach ($listeners as $listener) {
42 $listener->register();
43 } catch (Exception
$ex) {