|
|
@ -10,6 +10,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
namespace Mage\Command; |
|
|
|
namespace Mage\Command; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use Mage\Command\AbstractCommand; |
|
|
|
use Mage\Config; |
|
|
|
use Mage\Config; |
|
|
|
use Mage\Autoload; |
|
|
|
use Mage\Autoload; |
|
|
|
|
|
|
|
|
|
|
@ -39,13 +40,18 @@ class Factory |
|
|
|
$commandName = str_replace(' ', '_', ucwords(str_replace('/', ' ', $commandName))); |
|
|
|
$commandName = str_replace(' ', '_', ucwords(str_replace('/', ' ', $commandName))); |
|
|
|
$className = 'Mage\\Command\\BuiltIn\\' . $commandName . 'Command'; |
|
|
|
$className = 'Mage\\Command\\BuiltIn\\' . $commandName . 'Command'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!class_exists($className)) { |
|
|
|
|
|
|
|
// try a custom command |
|
|
|
|
|
|
|
$className = 'Command\\' . $commandName; |
|
|
|
|
|
|
|
|
|
|
|
if (!class_exists($className)) { |
|
|
|
if (!class_exists($className)) { |
|
|
|
throw new Exception('Command "' . $commandName . '" not found.'); |
|
|
|
throw new Exception('Command "' . $commandName . '" not found.'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** @var AbstractCommand $instance */ |
|
|
|
/** @var AbstractCommand $instance */ |
|
|
|
$instance = new $className; |
|
|
|
$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.'); |
|
|
|
throw new Exception('The command ' . $commandName . ' must be an instance of Mage\Command\AbstractCommand.'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|