refactored Autoloader; added support for json encoded format for environment "hosts" option

This commit is contained in:
Vladimir Grigor
2014-07-28 11:53:22 +03:00
parent 6ecaf41336
commit 5ce3394b3c
5 changed files with 71 additions and 49 deletions
+5 -9
View File
@@ -38,18 +38,14 @@ class Factory
$commandName = str_replace(' ', '_', ucwords(str_replace('/', ' ', $commandName)));
$className = 'Mage\\Command\\BuiltIn\\' . $commandName . 'Command';
if (Autoload::isLoadable($className)) {
$instance = new $className;
assert($instance instanceOf AbstractCommand);
$instance->setConfig($config);
} else {
throw new Exception('Command not found.');
}
if(!($instance instanceOf AbstractCommand)) {
/** @var AbstractCommand $instance */
$instance = new $className;
if(!is_a($instance, "Mage\Command\AbstractCommand")) {
throw new Exception('The command ' . $commandName . ' must be an instance of Mage\Command\AbstractCommand.');
}
$instance->setConfig($config);
return $instance;
}
}