|
|
@ -42,17 +42,14 @@ class Factory |
|
|
|
// try a custom command |
|
|
|
// try a custom command |
|
|
|
$className = 'Command\\' . $commandName; |
|
|
|
$className = 'Command\\' . $commandName; |
|
|
|
|
|
|
|
|
|
|
|
// TODO use a custom exception |
|
|
|
|
|
|
|
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 */ |
|
|
|
// TODO dependencies like $config should be injected into constructor |
|
|
|
|
|
|
|
$instance = new $className; |
|
|
|
$instance = new $className; |
|
|
|
if (! $instance instanceof AbstractCommand) { |
|
|
|
if (! $instance instanceof AbstractCommand) { |
|
|
|
// TODO use a custom exception |
|
|
|
|
|
|
|
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.'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|