public function init($config = null)
 {
     if (null == $config) {
         $routes = ConfigHandler::load('app.Config.routing', 'routing', true);
     } else {
         $routes = $config;
     }
     unset($routes['__urlSuffix__']);
     unset($routes['__remap__']);
     if ($routes and !empty($routes)) {
         foreach ($routes as $pattern => $config) {
             $this->addCollection(new Collection($config, $pattern));
         }
     }
     parent::init($config);
 }
 /**
  * Get Session
  * @deprecated Change method to \Flywheel\Session\Session::getInstance()
  *
  * @throws Exception
  * @return \Flywheel\Session\Session
  */
 public static function getSession()
 {
     if (!Base::getApp()) {
         throw new Exception('Factory: Session must start after the application is initialized!');
     }
     if (!isset(self::$_registry['session'])) {
         $config = ConfigHandler::load('app.config.session', 'session', false) or $config = ConfigHandler::load('global.config.session', 'session');
         if (false == $config) {
             throw new Exception('Session: config file not found, "session.cfg.php" must be exist at globals/config or ' . Base::getAppPath() . ' config directory');
         }
         $class = self::$_classesList['Session'];
         self::$_registry['session'] = new $class($config);
     }
     return self::$_registry['session'];
 }
 public function _loadConfig()
 {
     $this->_configParam = ConfigHandler::load('global.config.mongodb', 'mongodb');
     if ($this->_configParam) {
         $params = $this->_configParam;
         if ($params['host'] == "" || $params['port'] == "") {
             throw new Exception('No host or port configured to connect to Mongo');
         }
         if (!empty($params['db'])) {
             $this->db = $params['db'];
         } else {
             throw new Exception('No Mongo database selected');
         }
         $this->_dbname = $params['db'];
         $this->_replicaSet = $params['replica_set'];
         $this->_querySafety = $params['query_safety'];
         $this->_persistKey = $params['persist_key'];
         $this->_persist = $params['persist'];
         $this->_configData = array('hostname' => "mongodb://{$params['host']}:{$params['port']}/{$params['db']}", 'dsn' => "mongodb://{$params['host']}:{$params['port']}/{$params['db']}", 'persist' => true, 'persist_key' => $this->_persistKey, 'replica_set' => $this->_replicaSet, 'query_safety' => $this->_querySafety);
         $this->_dsn = $this->_configData['dsn'];
     }
 }