From d5dc0fa2e61d02f17993e99e7e02b70afa98a5c9 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 11 Feb 2019 15:37:19 +0200 Subject: [PATCH] console command changes --- .../Espo/Core/Console/CommandManager.php | 3 +++ application/Espo/Core/Utils/Util.php | 21 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/application/Espo/Core/Console/CommandManager.php b/application/Espo/Core/Console/CommandManager.php index 7f3395adbc..bc069061b4 100644 --- a/application/Espo/Core/Console/CommandManager.php +++ b/application/Espo/Core/Console/CommandManager.php @@ -40,7 +40,10 @@ class CommandManager public function run(string $command) { + $command = ucfirst(\Espo\Core\Utils\Util::hyphenToCamelCase($command)); + $className = '\\Espo\\Core\\Console\\Commands\\' . $command; + $className = $this->container->get('metadata')->get(['app', 'consoleCommands', $command, 'className'], $className); if (!class_exists($className)) { $msg = "Command '{$command}' does not exist."; echo $msg . "\n"; diff --git a/application/Espo/Core/Utils/Util.php b/application/Espo/Core/Utils/Util.php index 8e7390a39c..8b7d210295 100644 --- a/application/Espo/Core/Utils/Util.php +++ b/application/Espo/Core/Utils/Util.php @@ -38,7 +38,7 @@ class Util */ protected static $separator = DIRECTORY_SEPARATOR; - protected static $reservedWords = array('Case'); + protected static $reservedWordList = ['Case']; /** @@ -51,6 +51,16 @@ class Util return static::$separator; } + public static function camelCaseToUnderscore(string $string) : string + { + return static::toUnderScore($string); + } + + public static function hyphenToCamelCase(string $string) : string + { + return self::toCamelCase($string, '-'); + } + /** * Convert to format with defined delimeter @@ -136,11 +146,6 @@ class Util return static::fromCamelCase($name, '_'); } - public static function camelCaseToUnderscore($value) - { - return static::toUnderScore($value); - } - /** * Merge arrays recursively (default PHP function is not suitable) * @@ -299,7 +304,7 @@ class Util */ public static function normilizeClassName($name) { - if (in_array($name, self::$reservedWords)) { + if (in_array($name, self::$reservedWordList)) { $name .= 'Obj'; } return $name; @@ -313,7 +318,7 @@ class Util */ public static function normilizeScopeName($name) { - foreach (self::$reservedWords as $reservedWord) { + foreach (self::$reservedWordList as $reservedWord) { if ($reservedWord.'Obj' == $name) { return $reservedWord; }