mirror of
https://github.com/flarum/core.git
synced 2025-10-28 14:06:30 +01:00
Rename app to container (#2609)
* Rename `app` helper to `resolve`, deprecate old version * Rename $this->app to $this->container in service providers We no longer couple Flarum\Foundation\Application to the Laravel container; instead, we use the container separately. Changing our naming to reflect that will make things clearer.
This commit is contained in:
committed by
GitHub
parent
15cbe4daaa
commit
c81f629b0b
@@ -25,7 +25,7 @@ class LocaleServiceProvider extends AbstractServiceProvider
|
||||
public function boot(Dispatcher $events)
|
||||
{
|
||||
$events->listen(ClearingCache::class, function () {
|
||||
$this->app->make('flarum.locales')->clearCache();
|
||||
$this->container->make('flarum.locales')->clearCache();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ class LocaleServiceProvider extends AbstractServiceProvider
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton(LocaleManager::class, function () {
|
||||
$this->container->singleton(LocaleManager::class, function () {
|
||||
$locales = new LocaleManager(
|
||||
$this->app->make('translator'),
|
||||
$this->container->make('translator'),
|
||||
$this->getCacheDir()
|
||||
);
|
||||
|
||||
@@ -45,14 +45,14 @@ class LocaleServiceProvider extends AbstractServiceProvider
|
||||
return $locales;
|
||||
});
|
||||
|
||||
$this->app->alias(LocaleManager::class, 'flarum.locales');
|
||||
$this->container->alias(LocaleManager::class, 'flarum.locales');
|
||||
|
||||
$this->app->singleton('translator', function () {
|
||||
$this->container->singleton('translator', function () {
|
||||
$translator = new Translator(
|
||||
$this->getDefaultLocale(),
|
||||
null,
|
||||
$this->getCacheDir(),
|
||||
$this->app['flarum.debug']
|
||||
$this->container['flarum.debug']
|
||||
);
|
||||
|
||||
$translator->setFallbackLocales(['en']);
|
||||
@@ -62,20 +62,20 @@ class LocaleServiceProvider extends AbstractServiceProvider
|
||||
|
||||
return $translator;
|
||||
});
|
||||
$this->app->alias('translator', Translator::class);
|
||||
$this->app->alias('translator', TranslatorContract::class);
|
||||
$this->app->alias('translator', TranslatorInterface::class);
|
||||
$this->container->alias('translator', Translator::class);
|
||||
$this->container->alias('translator', TranslatorContract::class);
|
||||
$this->container->alias('translator', TranslatorInterface::class);
|
||||
}
|
||||
|
||||
private function getDefaultLocale(): string
|
||||
{
|
||||
$repo = $this->app->make(SettingsRepositoryInterface::class);
|
||||
$repo = $this->container->make(SettingsRepositoryInterface::class);
|
||||
|
||||
return $repo->get('default_locale', 'en');
|
||||
}
|
||||
|
||||
private function getCacheDir(): string
|
||||
{
|
||||
return $this->app[Paths::class]->storage.'/locale';
|
||||
return $this->container[Paths::class]->storage.'/locale';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user