예제 #1
0
 public function __construct()
 {
     $this->environment = isset($_SERVER['APPLICATION_ENV']) ? $_SERVER['APPLICATION_ENV'] : null;
     $config = new Config();
     $config->loadFromFile(CONFIG_DIR . 'cohesion-default-conf.json');
     $config->loadFromFile(CONFIG_DIR . 'default-conf.json');
     if ($this->environment) {
         $envConfFile = CONFIG_DIR . $this->environment . '-conf.json';
         if (file_exists($envConfFile)) {
             $config->loadFromFile($envConfFile);
         } else {
             throw new \Exception("Missing config file for {$this->environment} environment");
         }
     }
     $this->config = $config;
     $global = $config->get('global');
     $domain = $config->get('global.domain_name');
     if ($domain) {
         $global['abs_base_url'] = "http://{$domain}";
         $global['ssl_base_url'] = "https://{$domain}";
         $global['base_url'] = $global['abs_base_url'];
     }
     if ($this->environment == 'production' || $config->get('global.production')) {
         $global['production'] = true;
         $this->production = true;
     }
     if ($config->get('data_access.cache.driver') == 'APC') {
         $cache = new APC();
         $global['cache'] = $cache;
     }
     $config->merge('global', $global);
     RoutingFactory::$config = $this->getConfig('routing');
     ViewFactory::$config = $this->getConfig('view');
     ViewFactory::$environment = $this;
 }