diff --git a/src/Api/.ConfigLoader.php.swp b/src/Api/.ConfigLoader.php.swp deleted file mode 100644 index ff79c38..0000000 Binary files a/src/Api/.ConfigLoader.php.swp and /dev/null differ diff --git a/src/Api/ConfigLoader.php b/src/Api/ConfigLoader.php index 2dbca74..bdc3c36 100644 --- a/src/Api/ConfigLoader.php +++ b/src/Api/ConfigLoader.php @@ -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(); + } }