mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 18:12:59 +08:00
Experimenting with some new ways to handle config
For now I’ve chucked it on Flarum\Core as a static method, but ultimately I think we will need a ConfigRepository abstraction (whether it replaces or sits underneath the Flarum\Core static method I’m not sure). Also starting to think about multisite scenarios, I think this is important. The Forum model could actually end up with a database table behind it, and each forum would have its own config settings? Haven’t really thought about it too hard yet…
This commit is contained in:
parent
1adfe5d867
commit
53357ad56f
|
@ -1,9 +1,20 @@
|
|||
<?php namespace Flarum;
|
||||
|
||||
use DB;
|
||||
|
||||
class Core
|
||||
{
|
||||
public static function isInstalled()
|
||||
{
|
||||
return file_exists(base_path('../config.php'));
|
||||
}
|
||||
|
||||
public static function config($key, $default = null)
|
||||
{
|
||||
if (is_null($value = DB::table('config')->where('key', $key)->pluck('value'))) {
|
||||
$value = $default;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
<?php namespace Flarum\Core\Models;
|
||||
|
||||
use Tobscure\Permissible\Permissible;
|
||||
use Flarum\Core;
|
||||
|
||||
class Forum extends Model
|
||||
{
|
||||
use Permissible;
|
||||
|
||||
public function getTitleAttribute()
|
||||
{
|
||||
return Core::config('forum_title');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class ExtensionsServiceProvider extends ServiceProvider
|
|||
return;
|
||||
}
|
||||
|
||||
$extensions = json_decode(DB::table('config')->where('key', 'extensions_enabled')->pluck('value'), true);
|
||||
$extensions = json_decode(Core::config('extensions_enabled'), true);
|
||||
$providers = [];
|
||||
|
||||
foreach ($extensions as $extension) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user