Config and api client
This commit is contained in:
parent
b844195ff3
commit
401a5ba1b0
Binary file not shown.
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue