Example #1
0
 /**
  * Initialize the application, configure the settings, inject dependencies
  * Adjust the settings necessary for running the system
  */
 public function init()
 {
     if ($this->_init) {
         return;
     }
     date_default_timezone_set($this->_config->get('timezone'));
     /*
      * Init cache connection
      */
     $this->_initCache();
     /*
      * Init database connection
      */
     $conManager = $this->_initDb();
     /*
      * Apply configs
      */
     Filter::setDelimiter($this->_config->get('urlDelimiter'));
     Request::setDelimiter($this->_config->get('urlDelimiter'));
     Request::setExtension($this->_config->get('urlExtension'));
     Request::setRoot($this->_config->get('wwwroot'));
     Resource::setCachePaths($this->_config->get('jsCacheSysUrl'), $this->_config->get('jsCacheSysPath'));
     Resource::setDocRoot($this->_config->get('docroot'));
     Resource::setResourceRoot($this->_config->get('wwwroot'));
     Utils::setSalt($this->_config->get('salt'));
     /*
      * Init lang dictionary (Lazy Load)
      */
     $lang = $this->_config->get('language');
     Lang::addDictionaryLoader($lang, $this->_config->get('docroot') . '/system/lang/' . $lang . '.php', Config::File_Array);
     Lang::setDefaultDictionary($this->_config->get('language'));
     $eventManager = new Eventmanager();
     if ($this->_cache) {
         $eventManager->setCache($this->_cache);
         Resource::setCache($this->_cache);
         Template::setCache($this->_cache);
         if ($this->_config->offsetExists('template_check_mtime')) {
             Template::checkMtime($this->_config->get('template_check_mtime'));
         }
     }
     /*
      * Prepare Db object storage
      */
     $objectStore = new Db_Object_Store();
     $objectStore->setEventManager($eventManager);
     $objectStore->setLinksObjectName($this->_config->get('orm_links_object'));
     $objectStore->setHistoryObject($this->_config->get('orm_history_object'));
     $objectStore->setVersionObject($this->_config->get('orm_version_object'));
     /*
      * Prepare models
      */
     Model::setDataCache($this->_cache);
     Model::setGlobalHardcacheTime($this->_config->get('frontend_hardcache'));
     Model::setGlobalObjectStore($objectStore);
     Model::setDefaultDbManager($conManager);
     /*
      * Prepare Db_Object
      */
     $translator = new Db_Object_Config_Translator($this->_config->get('lang_path') . $this->_config->get('language') . '/objects.php');
     $translator->addTranslations(array($this->_config->get('lang_path') . $this->_config->get('language') . '/system_objects.php'));
     Db_Object_Config::setConfigPath($this->_config->get('object_configs'));
     Db_Object_Config::setTranslator($translator);
     if ($this->_config->get('db_object_error_log')) {
         $log = new Log_File($this->_config->get('db_object_error_log_path'));
         /*
          * Switch to Db_Object error log
          */
         if ($this->_config->get('erorr_log_object')) {
             $errorModel = Model::factory($this->_config->get('erorr_log_object'));
             $errorTable = $errorModel->table(true);
             $errorDb = $errorModel->getDbConnection();
             $logOrmDb = new Log_Db('db_object_error_log', $errorDb, $errorTable);
             $logModelDb = new Log_Db('model', $errorDb, $errorTable);
             Db_Object::setLog(new Log_Mixed($log, $logOrmDb));
             Model::setDefaultLog(new Log_Mixed($log, $logModelDb));
             $objectStore->setLog($logOrmDb);
         } else {
             Db_Object::setLog($log);
             Model::setDefaultLog($log);
             $objectStore->setLog($log);
         }
     }
     /*
      * Prepare dictionaries
      */
     Dictionary::setConfigPath($this->_config->get('dictionary'));
     /*
      * Prepare Controllers
      */
     Controller::setDefaultDb($this->_db);
     /*
      * Prepare Externals
      */
     if ($this->_config->get('allow_externals')) {
         $this->_initExternals();
     }
     $this->_init = true;
 }