IniParser::parseIniFile(): return a Config instance

refs #10150
This commit is contained in:
Alexander A. Klimov 2015-09-22 14:46:15 +02:00
parent a090907373
commit 8dc9928cb3
2 changed files with 4 additions and 5 deletions

View File

@ -314,9 +314,7 @@ class Config implements Countable, Iterator, Selectable
if ($filepath === false) {
$emptyConfig->setConfigFile($file);
} elseif (is_readable($filepath)) {
$config = static::fromArray(IniParser::parseIniFile($filepath)->toArray());
$config->setConfigFile($filepath);
return $config;
return IniParser::parseIniFile($filepath);
} elseif (@file_exists($filepath)) {
throw new NotReadableError(t('Cannot read config file "%s". Permission denied'), $filepath);
}

View File

@ -10,6 +10,7 @@ use Icinga\File\Ini\Dom\Directive;
use Icinga\Application\Logger;
use Icinga\Exception\ConfigurationError;
use Icinga\Exception\NotReadableError;
use Icinga\Application\Config;
class IniParser
{
@ -246,7 +247,7 @@ class IniParser
*
* @param string $file The ini file to read
*
* @return Document A mutable DOM object
* @return Config
* @throws NotReadableError When the file cannot be read
*/
public static function parseIniFile($file)
@ -259,6 +260,6 @@ class IniParser
throw new NotReadableError('Couldn\'t read the file `%s\'', $path);
}
return self::parseIni($content);
return Config::fromArray(self::parseIni($content)->toArray())->setConfigFile($file);
}
}