Bug #27820

CLI arguments are not working for camelCased commands

Added by Bastian Waidelich about 10 years ago. Updated about 10 years ago.

Status:
Resolved
Priority:
Should have
Assignee:
Category:
MVC
Start date:
2011-07-03
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Complexity:

Description

If a CLI command method name contains uppercase characters, CLI arguments are not properly resolved because ReflectionService won't find the actual method if you don't call the command in the correct case.

A todo comment for CommandController::resolveCommandMethodName() already states

@todo Find exact case of command method!

To be in sync with the Web request handling, this shouldn't happen in the controller though, but in the CLI request:
Chaning

public function getControllerCommandName() {
    return $this->controllerCommandName;
}

to:
public function getControllerCommandName() {
    $controllerObjectName = $this->getControllerObjectName();
    if ($controllerObjectName !== '' && ($this->controllerCommandName === strtolower($this->controllerCommandName)))  {
        $controllerClassName = $this->objectManager->getClassNameByObjectName($controllerObjectName);
        $commandMethodName = $this->controllerCommandName . 'Command';
        foreach (get_class_methods($controllerClassName) as $existingMethodName) {
            if (strtolower($existingMethodName) === strtolower($commandMethodName)) {
                $this->controllerCommandName = substr($existingMethodName, 0, -7);
                break;
            }
        }
    }
    return $this->controllerCommandName;
}

should do the trick, but I failed injecting the objectManager (for compile time commands)


Related issues

Related to TYPO3.Flow - Bug #7727: Better handling of "wrong" parameters in ./flow3ResolvedRobert Lemke2010-05-09

Actions
Related to TYPO3.Flow - Feature #27563: Implement simple argument support for CommandControllerResolved2011-06-20

Actions

Also available in: Atom PDF