mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 16:32:45 +08:00
Register database and cache implementations as binding for the settings repository
This commit is contained in:
parent
498a67e5bc
commit
91d9361693
|
@ -18,10 +18,6 @@ class Core
|
|||
return $default;
|
||||
}
|
||||
|
||||
if (is_null($value = app('flarum.db')->table('config')->where('key', $key)->pluck('value'))) {
|
||||
$value = $default;
|
||||
}
|
||||
|
||||
return $value;
|
||||
return app('Flarum\Core\Settings\SettingsRepository')->get($key, $default);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php namespace Flarum\Core;
|
||||
|
||||
use Flarum\Core\Settings\CachedSettingsRepository;
|
||||
use Flarum\Core\Settings\DatabaseSettingsRepository;
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Support\ServiceProvider;
|
||||
use Flarum\Extend;
|
||||
|
@ -31,6 +33,14 @@ class CoreServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton('Flarum\Core\Settings\SettingsRepository', function() {
|
||||
return new CachedSettingsRepository(
|
||||
new DatabaseSettingsRepository(
|
||||
$this->app->make('Illuminate\Database\ConnectionInterface')
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
$this->app->singleton('flarum.forum', 'Flarum\Core\Forum');
|
||||
|
||||
// TODO: probably use Illuminate's AggregateServiceProvider
|
||||
|
|
Loading…
Reference in New Issue
Block a user