/** * @param $name */ private function _loadConfigFile($name) { $lowercaseName = StringHelper::toLowerCase($name); // Is this a valid Craft config file? if (ConfigFile::isValidName($name)) { $defaultsPath = CRAFT_APP_PATH . 'etc/config/defaults/' . $name . '.php'; } else { $defaultsPath = CRAFT_PLUGINS_PATH . $lowercaseName . '/config.php'; } if (IOHelper::fileExists($defaultsPath)) { $defaultsConfig = @(require_once $defaultsPath); } if (!isset($defaultsConfig) || !is_array($defaultsConfig)) { $defaultsConfig = array(); } // Little extra logic for the general config file. if ($name == ConfigFile::General) { // Does craft/config/general.php exist? (It used to be called blocks.php so maybe not.) if (file_exists(CRAFT_CONFIG_PATH . 'general.php')) { if (is_array($customConfig = @(include CRAFT_CONFIG_PATH . 'general.php'))) { $this->_mergeConfigs($defaultsConfig, $customConfig); } } else { if (file_exists(CRAFT_CONFIG_PATH . 'blocks.php')) { // Originally blocks.php defined a $blocksConfig variable, and then later returned an array directly. if (is_array($customConfig = (require_once CRAFT_CONFIG_PATH . 'blocks.php'))) { $this->_mergeConfigs($defaultsConfig, $customConfig); } else { if (isset($blocksConfig)) { $defaultsConfig = array_merge($defaultsConfig, $blocksConfig); unset($blocksConfig); } } } } } else { $customConfigPath = CRAFT_CONFIG_PATH . $name . '.php'; if (!IOHelper::fileExists($customConfigPath)) { // Be a little forgiving on case sensitive file systems. $customConfigPath = CRAFT_CONFIG_PATH . StringHelper::toLowerCase($name) . '.php'; } if (IOHelper::fileExists($customConfigPath)) { if (is_array($customConfig = @(include $customConfigPath))) { $this->_mergeConfigs($defaultsConfig, $customConfig); } else { if ($name == ConfigFile::Db) { // Originally db.php defined a $dbConfig variable. if (@(require_once CRAFT_CONFIG_PATH . 'db.php')) { $this->_mergeConfigs($defaultsConfig, $dbConfig); unset($dbConfig); } } } } } $this->_loadedConfigFiles[$lowercaseName] = $defaultsConfig; }