From ba594de13a033480834d53d73f747b05fe9796f8 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 19 Dec 2018 21:30:29 +0100 Subject: [PATCH] Make site extenders run after extensions Fixes #1708. --- src/Extension/ExtensionServiceProvider.php | 2 +- src/Foundation/InstalledSite.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Extension/ExtensionServiceProvider.php b/src/Extension/ExtensionServiceProvider.php index fa61df382..fe5135628 100644 --- a/src/Extension/ExtensionServiceProvider.php +++ b/src/Extension/ExtensionServiceProvider.php @@ -27,7 +27,7 @@ class ExtensionServiceProvider extends AbstractServiceProvider // 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 boot code runs. + // container before the core boots up (and starts resolving services). $this->app->booting(function (Container $app) { $app->make('flarum.extensions')->extend($app); }); diff --git a/src/Foundation/InstalledSite.php b/src/Foundation/InstalledSite.php index 8e516ef0b..de15623bd 100644 --- a/src/Foundation/InstalledSite.php +++ b/src/Foundation/InstalledSite.php @@ -36,6 +36,7 @@ use Illuminate\Cache\Repository as CacheRepository; use Illuminate\Config\Repository as ConfigRepository; use Illuminate\Contracts\Cache\Repository; use Illuminate\Contracts\Cache\Store; +use Illuminate\Contracts\Container\Container; use Illuminate\Filesystem\Filesystem; use Illuminate\Filesystem\FilesystemServiceProvider; use Illuminate\Hashing\HashServiceProvider; @@ -146,9 +147,14 @@ class InstalledSite implements SiteInterface $laravel->register(ExtensionServiceProvider::class); - foreach ($this->extenders as $extension) { - $extension->extend($laravel); - } + $laravel->booting(function (Container $app) { + // Run all local-site extenders before booting service providers + // (but after those from "real" extensions, which have been set up + // in a service provider above). + foreach ($this->extenders as $extension) { + $extension->extend($app); + } + }); $laravel->boot();