From 4b177535e4ffb69229faa944fc08c332bee26c3c Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Mon, 20 Jun 2022 20:53:04 +0100 Subject: [PATCH] Moved plugin replacement namespace aliasing into register replacement method --- modules/system/classes/PluginManager.php | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/modules/system/classes/PluginManager.php b/modules/system/classes/PluginManager.php index f2ba9cdbbc..04fed249d8 100644 --- a/modules/system/classes/PluginManager.php +++ b/modules/system/classes/PluginManager.php @@ -324,20 +324,6 @@ public function registerPlugin(PluginBase $plugin, ?string $pluginId = null): vo View::addNamespace($pluginNamespace, $viewsPath); } - /* - * Register namespace aliases for any replaced plugins - */ - if ($replaces = $plugin->getReplaces()) { - foreach ($replaces as $replace) { - $replaceNamespace = $this->getNamespace($replace); - - $this->app->make(ClassLoader::class)->addNamespaceAliases([ - // class_alias() expects order to be $real, $alias - $this->getNamespace($pluginId) => $replaceNamespace, - ]); - } - } - /** * Disable plugin registration for restricted pages, unless elevated */ @@ -734,6 +720,12 @@ protected function registerPluginReplacements(): void foreach ($this->replacementMap as $target => $replacement) { // Alias the replaced plugin to the replacing plugin $this->aliasPluginAs($replacement, $target); + + // Register namespace aliases for any replaced plugins + $this->app->make(ClassLoader::class)->addNamespaceAliases([ + // class_alias() expects order to be $real, $alias + $this->getNamespace($replacement) => $this->getNamespace($target), + ]); } }