/** * Load preferences from source * * @return array * * @throws NotReadableError When the INI file of the user exists and is not readable */ public function load() { if (file_exists($this->preferencesFile)) { if (!is_readable($this->preferencesFile)) { throw new NotReadableError('Preferences INI file %s for user %s is not readable', $this->preferencesFile, $this->getUser()->getUsername()); } else { $this->preferences = IniParser::parseIniFile($this->preferencesFile)->toArray(); } } return $this->preferences; }
/** * Load configuration from the given INI file * * @param string $file The file to parse * * @throws NotReadableError When the file cannot be read */ public static function fromIni($file) { $emptyConfig = new static(); $filepath = realpath($file); if ($filepath === false) { $emptyConfig->setConfigFile($file); } elseif (is_readable($filepath)) { return IniParser::parseIniFile($filepath); } elseif (@file_exists($filepath)) { throw new NotReadableError(t('Cannot read config file "%s". Permission denied'), $filepath); } return $emptyConfig; }