Move settings repositories to own namespace

Also add a third method to the contract. This will help with building a caching decorator.
This commit is contained in:
Franz Liedke 2015-07-15 23:16:57 +02:00
parent 76678f72f2
commit 8e9cf4fd2e
2 changed files with 11 additions and 4 deletions

View File

@ -1,10 +1,10 @@
<?php <?php
namespace Flarum\Core; namespace Flarum\Core\Settings;
use Illuminate\Database\ConnectionInterface; use Illuminate\Database\ConnectionInterface;
class DatabaseSettingsRepository implements SettingsRepositoryInterface class DatabaseSettingsRepository implements SettingsRepository
{ {
protected $database; protected $database;
@ -13,6 +13,11 @@ class DatabaseSettingsRepository implements SettingsRepositoryInterface
$this->database = $connection; $this->database = $connection;
} }
public function all()
{
return $this->database->table('config')->lists('value', 'key');
}
public function get($key, $default = null) public function get($key, $default = null)
{ {
if (is_null($value = $this->database->table('config')->where('key', $key)->pluck('value'))) { if (is_null($value = $this->database->table('config')->where('key', $key)->pluck('value'))) {

View File

@ -1,9 +1,11 @@
<?php <?php
namespace Flarum\Core; namespace Flarum\Core\Settings;
interface SettingsRepositoryInterface interface SettingsRepository
{ {
public function all();
public function get($key, $default = null); public function get($key, $default = null);
public function set($key, $value); public function set($key, $value);