|
|
@ -33,13 +33,14 @@ class Factory |
|
|
|
public static function get($commandName, Config $config) |
|
|
|
public static function get($commandName, Config $config) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$instance = null; |
|
|
|
$instance = null; |
|
|
|
$commandName = ucwords(str_replace('-', ' ', $commandName)); |
|
|
|
$commandName = ucwords(str_replace('-', ' ', $commandName)); |
|
|
|
$commandName = str_replace(' ', '', $commandName); |
|
|
|
$commandName = str_replace(' ', '', $commandName); |
|
|
|
|
|
|
|
|
|
|
|
$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 (Autoload::isLoadable($className)) { |
|
|
|
if (Autoload::isLoadable($className)) { |
|
|
|
$instance = new $className; |
|
|
|
$instance = new $className; |
|
|
|
|
|
|
|
assert($instance instanceOf AbstractCommand); |
|
|
|
$instance->setConfig($config); |
|
|
|
$instance->setConfig($config); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
throw new Exception('Command not found.'); |
|
|
|
throw new Exception('Command not found.'); |
|
|
|