From 1120f01083beff557a5ce1c096fcedb6138fbc89 Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Sun, 5 Jan 2025 15:18:26 +0000 Subject: [PATCH] Made plugin guessing even simplier --- .../classes/extensions/source/ExtensionSource.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/modules/system/classes/extensions/source/ExtensionSource.php b/modules/system/classes/extensions/source/ExtensionSource.php index 7e578d19b..85bc0129b 100644 --- a/modules/system/classes/extensions/source/ExtensionSource.php +++ b/modules/system/classes/extensions/source/ExtensionSource.php @@ -289,18 +289,13 @@ protected function guessCodeFromPath(string $path): ?string */ protected function guessCodeFromPlugin(string $path): string { - // Get all files in the provided path - $files = array_combine(array_map('strtolower', $files = scandir($path)), $files); + $plugins = PluginManager::instance()->findPluginsInPath($path); - // If there is no plugin.php in any casing, then throw - if (!isset($files['plugin.php'])) { + if (count($plugins) !== 1) { throw new ApplicationException(sprintf('Unable to locate plugin file in path: "%s"', $path)); } - // Create a full path to the plugin.php file - $file = $path . DIRECTORY_SEPARATOR . $files['plugin.php']; - - return PluginManager::instance()->extractPluginCodeFromFile($file); + return array_keys($plugins)[0]; } protected function relativePath(string $path): string