mirror of
https://github.com/flarum/framework.git
synced 2025-02-18 09:12:45 +08:00
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:
parent
76678f72f2
commit
8e9cf4fd2e
|
@ -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'))) {
|
|
@ -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);
|
Loading…
Reference in New Issue
Block a user