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