Config and api client

This commit is contained in:
Simon Vieille 2015-02-10 02:05:21 +01:00
parent b844195ff3
commit 401a5ba1b0
2 changed files with 17 additions and 1 deletions

Binary file not shown.

View file

@ -3,6 +3,7 @@
namespace Api;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Yaml\Yaml;
class ConfigLoader
{
@ -10,7 +11,7 @@ class ConfigLoader
protected $filesystem = null;
protected function __construct()
public function __construct()
{
$this->filesystem = new Filesystem();
}
@ -19,4 +20,19 @@ class ConfigLoader
{
return $this->filesystem->exists($this->configFile);
}
public function save(array $data)
{
$config = array_merge(
$this->getConfig(),
$data
);
$this->filesystem->dumpFile($this->configFile, Yaml::dump($config));
}
public function getConfig()
{
return $this->configExists() ? Yaml::parse($this->configFile) : array();
}
}