From 12dd550a148755c66ede3c16bc7659248a2e9adb Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 1 Jul 2015 23:08:26 +0200 Subject: [PATCH] Add settings repository interface and database implementation. Almost done with flarum/core#121 now. --- src/Core/DatabaseSettingsRepository.php | 29 ++++++++++++++++++++++++ src/Core/SettingsRepositoryInterface.php | 10 ++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/Core/DatabaseSettingsRepository.php create mode 100644 src/Core/SettingsRepositoryInterface.php diff --git a/src/Core/DatabaseSettingsRepository.php b/src/Core/DatabaseSettingsRepository.php new file mode 100644 index 000000000..c7d86d5c2 --- /dev/null +++ b/src/Core/DatabaseSettingsRepository.php @@ -0,0 +1,29 @@ +database = $connection; + } + + public function get($key, $default = null) + { + if (is_null($value = $this->database->table('config')->where('key', $key)->pluck('value'))) { + return $default; + } + + return $value; + } + + public function set($key, $value) + { + $this->database->table('config')->where('key', $key)->update(['value' => $value]); + } +} diff --git a/src/Core/SettingsRepositoryInterface.php b/src/Core/SettingsRepositoryInterface.php new file mode 100644 index 000000000..5007e0f06 --- /dev/null +++ b/src/Core/SettingsRepositoryInterface.php @@ -0,0 +1,10 @@ +