console command changes

This commit is contained in:
yuri
2019-02-11 15:37:19 +02:00
parent 8cb9568334
commit d5dc0fa2e6
2 changed files with 16 additions and 8 deletions

View File

@@ -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";

View File

@@ -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;
}