Bug #27820

CLI arguments are not working for camelCased commands

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

Status:Resolved Start date:2011-07-03
Priority:Should have Due date:
Assigned To:Robert Lemke % Done:

100%

Category:MVC
Target version:TYPO3 Flow Base Distribution - 1.0 beta 1
PHP Version: Complexity:
Has patch: Affected Flow version:

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 ./flow3 Resolved 2010-05-09
related to TYPO3.Flow - Feature #27563: Implement simple argument support for CommandController Resolved 2011-06-20

Associated revisions

Revision cb489cc5
Added by Robert Lemke about 4 years ago

[FEATURE] Shorthand command commands and arguments

This allows to type just controllername:commandname if this uniquely
identifies a package / controller /command method in the system.
Hence you can just type ./flow3 kickstart:package Foo.Bar

A second feature added is that named (required) arguments can be
specified without the argument name (like the package key Foo.Bar
above) as long as all required arguments are specified that way and
in the correct order. Optional arguments must always be named and
specified before the named arguments.

The CLI request now also provides a getExceedingArguments() method and
this fixes a small bug related to camel cased controller names.

Change-Id: I89ab55f99c0ea35a66167b485b62238034e10bc7
Resolves: #27563
Resolves: #27820

History

#1 Updated by Karsten Dambekalns about 4 years ago

  • Status changed from New to Accepted
  • Assigned To set to Robert Lemke
  • Target version set to 1.0 beta 1

#2 Updated by Mr. Hudson about 4 years ago

  • Status changed from Accepted to Under Review

Patch set 1 of change I89ab55f99c0ea35a66167b485b62238034e10bc7 has been pushed to the review server.
It is available at http://review.typo3.org/3124

#3 Updated by Robert Lemke about 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF