Register database and cache implementations as binding for the settings repository

This commit is contained in:
Franz Liedke 2015-07-15 23:54:56 +02:00
parent 498a67e5bc
commit 91d9361693
2 changed files with 11 additions and 5 deletions

View File

@ -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);
}
}

View File

@ -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