예제 #1
0
 /**
  * Inits Cfg service
  *
  * Creates Cfg service instance.
  * Loads config data from db
  * Sets essential configs from Settings.php
  * Set basic paths and urls which are used by framework component.
  *
  * @return void
  */
 private function initConfig()
 {
     // Admin users can request to load config from db instead out of cache
     // @TODO Cache not implemented for now
     #$refresh_cache = isset($this->user) && $this->user->getAdmin() && isset($_REQUEST['refresh_config_cache']);
     $repository = new \Core\Config\Repository\DbRepository();
     $repository->setPdo($this->di->get('db.default.conn'));
     $repository->setTable('tekfw_core_configs');
     $this->config = new \Core\Config\Config($repository);
     // Create the Core config storage
     $core_storage = $this->config->createStorage('Core');
     // Load config from repository
     $this->config->load();
     // Make sure sites protocol is set
     if (empty($this->settings['protcol'])) {
         $this->settings['protocol'] = 'http';
     }
     // Check for baseurl or stop here
     if (empty($this->settings['baseurl'])) {
         throw new FrameworkException('Baseurl not set in Settings.php');
     }
     // Define some basic url constants
     define('BASEURL', $this->settings['protocol'] . '://' . $this->settings['baseurl']);
     define('THEMESURL', BASEURL . '/Themes');
     $core_storage->set('site.protocol', $this->settings['protocol']);
     $core_storage->set('site.baseurl', $this->settings['baseurl']);
     // Check and set basic cookiename to config
     if (empty($this->settings['cookie'])) {
         throw new FrameworkException('Cookiename not set in Settings.php');
     }
     $core_storage->set('cookie.name', $this->settings['cookie']);
     // Add dirs to config
     $dirs = ['fw' => $this->basedir . '/Core', 'assets' => $this->basedir . '/Assets', 'lib' => $this->basedir . '/Core', 'html' => $this->basedir . '/Core/Html', 'cache' => $this->basedir . '/Cache', 'apps' => $this->basedir . '/Apps'];
     $core_storage->addPaths($dirs);
     // Add urls to config
     $urls = ['apps' => BASEURL . '/Apps', 'cache' => BASEURL . '/Cache', 'vendor' => BASEURL . '/vendor', 'vendor_tekkla' => BASEURL . '/vendor/tekkla'];
     $core_storage->addUrls($urls);
     $this->di->mapValue('core.config', $this->config);
 }