1
0
mirror of https://github.com/flarum/core.git synced 2025-07-20 16:21:18 +02:00

Resolve extenders from ExtensionManager

Loading the activated extensions now means retrieving an array of
extenders (classes that implement a certain type of extension of a core
feature in Flarum).

For now, the only existing extender is the Compat extender which is used
to handle old-style bootstrappers that simply return a closure that
receives all of its dependencies via auto injection.

In the future, extensions will be able to return an array of extender
instances from their bootstrapper instead. These extender classes will
be implemented in the next step.
This commit is contained in:
Franz Liedke
2017-10-03 16:15:12 +02:00
parent c41e58531a
commit 5b6d043f80
5 changed files with 89 additions and 15 deletions

View File

@@ -12,6 +12,7 @@
namespace Flarum\Extension;
use Flarum\Foundation\AbstractServiceProvider;
use Illuminate\Contracts\Container\Container;
class ExtensionServiceProvider extends AbstractServiceProvider
{
@@ -22,13 +23,14 @@ class ExtensionServiceProvider extends AbstractServiceProvider
{
$this->app->bind('flarum.extensions', ExtensionManager::class);
$bootstrappers = $this->app->make('flarum.extensions')->getEnabledBootstrappers();
$this->app->booting(function (Container $app) {
/** @var \Flarum\Extend\Extender[] $extenders */
$extenders = $app->make('flarum.extensions')->getActiveExtenders();
foreach ($bootstrappers as $file) {
$bootstrapper = require $file;
$this->app->call($bootstrapper);
}
foreach ($extenders as $extender) {
$extender->apply($app);
}
});
}
/**