Path: blob/master/src/infrastructure/events/PhabricatorEventEngine.php
12249 views
<?php12final class PhabricatorEventEngine extends Phobject {34public static function initialize() {5// NOTE: If any of this fails, we just log it and move on. It's important6// to try to make it through here because users may have difficulty fixing7// fix the errors if we don't: for example, if we fatal here a user may not8// be able to run `bin/config` in order to remove an invalid listener.910// Load automatic listeners.11$listeners = id(new PhutilClassMapQuery())12->setAncestorClass('PhabricatorAutoEventListener')13->execute();1415// Load configured listeners.16$config_listeners = PhabricatorEnv::getEnvConfig('events.listeners');17foreach ($config_listeners as $listener_class) {18try {19$listeners[] = newv($listener_class, array());20} catch (Exception $ex) {21phlog($ex);22}23}2425// Add built-in listeners.26$listeners[] = new DarkConsoleEventPluginAPI();2728// Add application listeners.29$applications = PhabricatorApplication::getAllInstalledApplications();30foreach ($applications as $application) {31$app_listeners = $application->getEventListeners();32foreach ($app_listeners as $listener) {33$listener->setApplication($application);34$listeners[] = $listener;35}36}3738// Now, register all of the listeners.39foreach ($listeners as $listener) {40try {41$listener->register();42} catch (Exception $ex) {43phlog($ex);44}45}46}4748}495051