From 3c84337da7ab4da0eb1e7bec2d17f3b3a8bfe1a5 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Thu, 29 May 2014 17:33:02 +1000 Subject: [PATCH] Fixes #222 - Plugin commands are now case insensitive --- modules/system/classes/PluginManager.php | 17 ++++++++++++++++- modules/system/console/PluginRefresh.php | 3 +++ modules/system/console/PluginRemove.php | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/system/classes/PluginManager.php b/modules/system/classes/PluginManager.php index 0a26cd267..501a6c7ae 100644 --- a/modules/system/classes/PluginManager.php +++ b/modules/system/classes/PluginManager.php @@ -254,7 +254,7 @@ class PluginManager public function findByIdentifier($identifier) { if (!isset($this->plugins[$identifier])) - return null; + $identifier = $this->normalizeIdentifier($identifier); return $this->plugins[$identifier]; } @@ -328,6 +328,21 @@ class PluginManager return $namespace; } + /** + * Takes a human plugin code (acme.blog) and makes it authentic (Acme.Blog) + * @param string $id + * @return string + */ + public function normalizeIdentifier($identifier) + { + foreach ($this->plugins as $id => $object) { + if (strtolower($id) == strtolower($identifier)) + return $id; + } + + return $identifier; + } + // // Disability // diff --git a/modules/system/console/PluginRefresh.php b/modules/system/console/PluginRefresh.php index f2f8baf09..9f7e2c899 100644 --- a/modules/system/console/PluginRefresh.php +++ b/modules/system/console/PluginRefresh.php @@ -2,6 +2,7 @@ use Illuminate\Console\Command; use System\Classes\UpdateManager; +use System\Classes\PluginManager; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; @@ -36,6 +37,8 @@ class PluginRefresh extends Command public function fire() { $pluginName = $this->argument('name'); + $pluginName = PluginManager::instance()->normalizeIdentifier($pluginName); + $manager = UpdateManager::instance()->resetNotes(); $manager->rollbackPlugin($pluginName); diff --git a/modules/system/console/PluginRemove.php b/modules/system/console/PluginRemove.php index c3a321579..c51e60ab1 100644 --- a/modules/system/console/PluginRemove.php +++ b/modules/system/console/PluginRemove.php @@ -39,6 +39,7 @@ class PluginRemove extends Command { if ($this->confirm('Are you sure you want to uninstall this plugin? [yes|no]')) { $pluginName = $this->argument('name'); + $pluginName = PluginManager::instance()->normalizeIdentifier($pluginName); /* * Rollback plugin