protected function __construct()
 {
     $this->enabled = extension_loaded('mysql') && Config::getInstance()->enabled;
     if ($this->enabled) {
         $this->setUpDatabase();
         $this->setData('config', \ManiaLive\Config\Config::getInstance());
         $this->setData('wsapi', \ManiaLive\Features\WebServices\Config::getInstance());
         $this->setData('manialive', \ManiaLive\Application\Config::getInstance());
         $this->setData('server', \ManiaLive\DedicatedApi\Config::getInstance());
         $this->setData('threading', \ManiaLive\Threading\Config::getInstance());
     } else {
         Logger::debug('Application started with threading disabled!', true, array('Process #' . getmypid()));
         $this->buffers[0] = array();
     }
     Dispatcher::register(TickEvent::getClass(), $this);
 }
Exemple #2
0
 private function initDatabase()
 {
     $options = getopt(null, array('dbHost::', 'dbPort::', 'dbUsername::', 'dbPassword::', 'dbDatabase::'));
     $dbConfig = \ManiaLive\Database\Config::getInstance();
     foreach ($options as $key => $value) {
         $dbConfig->{lcfirst(substr($key, 2))} = $value;
     }
     $this->database = Connection::getConnection($dbConfig->host, $dbConfig->username, $dbConfig->password, $dbConfig->database, 'MySQL', $dbConfig->port);
     // load configs from DB
     $configs = array('config' => \ManiaLive\Config\Config::getInstance(), 'wsapi' => \ManiaLive\Features\WebServices\Config::getInstance(), 'manialive' => \ManiaLive\Application\Config::getInstance(), 'server' => \ManiaLive\DedicatedApi\Config::getInstance(), 'threading' => Config::getInstance());
     foreach ($configs as $dbName => $instance) {
         $data = $this->getData($dbName, array());
         foreach ((array) $data as $key => $value) {
             $instance->{$key} = $value;
         }
     }
 }
 function onInit()
 {
     Console::println('[PluginHandler] Start plugin load process:');
     foreach (\ManiaLive\Application\Config::getInstance()->plugins as $pluginId) {
         try {
             $this->register($pluginId);
         } catch (\Exception $e) {
             $this->unload($pluginId);
             ErrorHandling::processRuntimeException($e);
         }
     }
     foreach ($this->loadedPlugins as $pluginId => $plugin) {
         try {
             $this->prepare($plugin);
         } catch (\Exception $e) {
             $this->unload($pluginId);
             ErrorHandling::processRuntimeException($e);
         }
     }
     foreach ($this->loadedPlugins as $plugin) {
         $plugin->onReady();
     }
     Console::println('[PluginHandler] All registered plugins have been loaded');
 }
 /**
  * Return the list of Admins' login
  * @return array
  */
 public static function get()
 {
     return \ManiaLive\Application\Config::getInstance()->admins;
 }