diff --git a/Mage/Autoload.php b/Mage/Autoload.php index 4d674c2..474aa0c 100644 --- a/Mage/Autoload.php +++ b/Mage/Autoload.php @@ -31,6 +31,11 @@ class Autoload if (strpos($className, 'Task\\') === 0) { $baseDir = getcwd() . '/.mage/tasks'; $postfix = substr($postfix, 5); + + } else if (strpos($className, 'Command\\') === 0) { + $baseDir = getcwd() . '/.mage/commands'; + $postfix = substr($postfix, 8); + } else { $baseDir = dirname(dirname(__FILE__)); } diff --git a/Mage/Command/Factory.php b/Mage/Command/Factory.php index 1ba9b4d..0584046 100644 --- a/Mage/Command/Factory.php +++ b/Mage/Command/Factory.php @@ -10,6 +10,7 @@ namespace Mage\Command; +use Mage\Command\AbstractCommand; use Mage\Config; use Mage\Autoload; @@ -40,12 +41,17 @@ class Factory $className = 'Mage\\Command\\BuiltIn\\' . $commandName . 'Command'; if (!class_exists($className)) { - throw new Exception('Command "' . $commandName . '" not found.'); + // try a custom command + $className = 'Command\\' . $commandName; + + if (!class_exists($className)) { + throw new Exception('Command "' . $commandName . '" not found.'); + } } /** @var AbstractCommand $instance */ $instance = new $className; - if (!is_a($instance, "Mage\Command\AbstractCommand")) { + if (! $instance instanceOf AbstractCommand) { throw new Exception('The command ' . $commandName . ' must be an instance of Mage\Command\AbstractCommand.'); }