import console command in classes

This commit is contained in:
Yuri Kuznetsov
2020-09-08 12:03:19 +03:00
parent aafa30dbf9
commit 1f07688881
3 changed files with 13 additions and 4 deletions
@@ -27,9 +27,12 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Console\Commands;
namespace Espo\Classes\ConsoleCommands;
use Espo\Core\ServiceFactory;
use Espo\Core\{
ServiceFactory,
Console\Commands\Command,
};
use Throwable;
@@ -79,12 +79,14 @@ class CommandManager
protected function getClassName(string $command) : string
{
$className =
$this->metadata->get(['app', 'consoleCommands', $command, 'className']) ??
$this->metadata->get(['app', 'consoleCommands', lcfirst($command), 'className']) ??
'Espo\\Core\\Console\\Commands\\' . $command;
if (!class_exists($className)) {
$msg = "Command '{$command}' does not exist.";
echo $msg . "\n";
throw new Error($msg);
}
@@ -1 +1,5 @@
{}
{
"import": {
"className": "Espo\\Classes\\ConsoleCommands\\Import"
}
}