1
0
mirror of https://github.com/flarum/core.git synced 2025-02-24 19:23:01 +01:00

Locale: Don't resolve manager just to configure it

Refs #1578.
This commit is contained in:
Franz Liedke 2018-12-19 22:07:20 +01:00
parent e4514d8413
commit 0e5f334a0b
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4

View File

@ -26,14 +26,8 @@ class LocaleServiceProvider extends AbstractServiceProvider
*/ */
public function boot(Dispatcher $events) public function boot(Dispatcher $events)
{ {
$locales = $this->app->make('flarum.locales'); $events->listen(ClearingCache::class, function () {
$this->app->make('flarum.locales')->clearCache();
$locales->addLocale($this->getDefaultLocale(), 'Default');
$events->dispatch(new ConfigureLocales($locales));
$events->listen(ClearingCache::class, function () use ($locales) {
$locales->clearCache();
}); });
} }
@ -43,10 +37,16 @@ class LocaleServiceProvider extends AbstractServiceProvider
public function register() public function register()
{ {
$this->app->singleton(LocaleManager::class, function () { $this->app->singleton(LocaleManager::class, function () {
return new LocaleManager( $locales = new LocaleManager(
$this->app->make('translator'), $this->app->make('translator'),
$this->getCacheDir() $this->getCacheDir()
); );
$locales->addLocale($this->getDefaultLocale(), 'Default');
event(new ConfigureLocales($locales));
return $locales;
}); });
$this->app->alias(LocaleManager::class, 'flarum.locales'); $this->app->alias(LocaleManager::class, 'flarum.locales');