Skip to content

Commit

Permalink
Made plugin guessing even simplier
Browse files Browse the repository at this point in the history
  • Loading branch information
jaxwilko committed Jan 5, 2025
1 parent f9773db commit 1120f01
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions modules/system/classes/extensions/source/ExtensionSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1120f01

Please sign in to comment.