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; }
public function __construct() { parent::__construct(); if (!isset($_SESSION)) { session_start(); } $this->input = new Input($_REQUEST ?: array()); $global = $this->config->get('global'); $this->supportedMimeTypes = $this->config->get('view.mime_types'); if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) { $global['protocol'] = 'https'; $this->isSecure = true; } else { $global['protocol'] = 'http'; $this->isSecure = false; } $domain = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'] ? $_SERVER['SERVER_NAME'] : null); if ($domain) { $global['domain'] = $domain; $global['abs_base_url'] = "http://{$domain}"; $global['ssl_base_url'] = "https://{$domain}"; $global['base_url'] = $global['protocol'] . '://' . $domain; } $global['web_root'] = $_SERVER['DOCUMENT_ROOT']; $global['base_dir'] = dirname($global['web_root']); $global['uri'] = explode('?', $_SERVER['REQUEST_URI'])[0]; $this->config->merge('global', $global); RoutingFactory::$config = $this->getConfig('routing'); ViewFactory::$config = $this->getConfig('view'); }