Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/events/PhabricatorEventEngine.php
12249 views
1
<?php
2
3
final class PhabricatorEventEngine extends Phobject {
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 PhutilClassMapQuery())
13
->setAncestorClass('PhabricatorAutoEventListener')
14
->execute();
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 built-in 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
}
50
51