1
0
mirror of https://github.com/flarum/core.git synced 2025-10-13 07:54:25 +02: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:
Alexander Skvortsov
2021-03-04 22:14:48 -05:00
committed by GitHub
parent 15cbe4daaa
commit c81f629b0b
29 changed files with 306 additions and 278 deletions

View File

@@ -132,7 +132,7 @@ class Extension implements Arrayable
$this->id = static::nameToId($this->name);
}
public function extend(Container $app)
public function extend(Container $container)
{
foreach ($this->getExtenders() as $extender) {
// If an extension has not yet switched to the new extend.php
@@ -142,7 +142,7 @@ class Extension implements Arrayable
$extender = new Compat($extender);
}
$extender->extend($app, $this);
$extender->extend($container, $this);
}
}

View File

@@ -341,12 +341,12 @@ class ExtensionManager
/**
* Call on all enabled extensions to extend the Flarum application.
*
* @param Container $app
* @param Container $container
*/
public function extend(Container $app)
public function extend(Container $container)
{
foreach ($this->getEnabledExtensions() as $extension) {
$extension->extend($app);
$extension->extend($container);
}
}

View File

@@ -19,15 +19,15 @@ class ExtensionServiceProvider extends AbstractServiceProvider
*/
public function register()
{
$this->app->singleton(ExtensionManager::class);
$this->app->alias(ExtensionManager::class, 'flarum.extensions');
$this->container->singleton(ExtensionManager::class);
$this->container->alias(ExtensionManager::class, 'flarum.extensions');
// Boot extensions when the app is booting. This must be done as a boot
// listener on the app rather than in the service provider's boot method
// below, so that extensions have a chance to register things on the
// container before the core boots up (and starts resolving services).
$this->app['flarum']->booting(function () {
$this->app->make('flarum.extensions')->extend($this->app);
$this->container['flarum']->booting(function () {
$this->container->make('flarum.extensions')->extend($this->container);
});
}
@@ -36,7 +36,7 @@ class ExtensionServiceProvider extends AbstractServiceProvider
*/
public function boot()
{
$this->app->make('events')->listen(
$this->container->make('events')->listen(
Disabling::class,
DefaultLanguagePackGuard::class
);