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