public function read($file)
{
if (!file_exists($file)) {
throw new Phergie_Config_Exception('File "' . $file . '" does not exist', Phergie_Config_Exception::ERR_FILE_NOT_FOUND);
}
if (!is_readable($file)) {
throw new Phergie_Config_Exception('File "' . $file . '" cannot be read', Phergie_Config_Exception::ERR_FILE_NOT_READABLE);
}
$settings = (include $file);
if (!is_array($settings)) {
throw new Phergie_Config_Exception('File "' . $file . '" does not return an array', Phergie_Config_Exception::ERR_ARRAY_NOT_RETURNED);
}
$this->files[$file] = array_keys($settings);
$this->settings += $settings;
return $this;
}
/** * Returns the entire configuration in use or the value of a specific * configuration setting. * * @param string $index Optional index of a specific configuration * setting for which the corresponding value should be returned * * @return mixed Value corresponding to $index or the entire * configuration if $index is not specified */ public function getConfig($index = null) { if (empty($this->config)) { $this->config = new Phergie_Config(); $this->config->read('Settings.php'); } if ($index !== null) { return $this->config[$index]; } return $this->config; }