#77647getControllerActionName in extbase\Classes\Mvc\Request.php forbit ActionNames in LowerCamelCase
Description
The documentation allow lowerCamelCase for actionnames within the controller.
https://docs.typo3.org/typo3cms/ExtbaseGuide/singlehtml/ (last visit 2016-08-27-19:30)
“…. allowed Actions are registered in ext_localconf.php and thenceforth only referenced by name. For example, list, show, detail, update, edit, delete. These names are also used within the page Uri. Within the ActionController, a lowerCamelCase name is required for every action: for example, the action list refers to the method listAction: ….
The Function getControllerActionName in extbase\Classes\Mvc\Request.php tests not with lcfirst for lowerCamelCase. It tests for general lowercase with strtolower.
public function getControllerActionName()
{
$controllerObjectName = $this->getControllerObjectName();
if ($controllerObjectName !== '' && $this->controllerActionName === strtolower($this->controllerActionName)) {
$actionMethodName = $this->controllerActionName . 'Action';
$classMethods = get_class_methods($controllerObjectName);
if (is_array($classMethods)) {
foreach ($classMethods as $existingMethodName) {
if (strtolower($existingMethodName) === strtolower($actionMethodName)) {
$this->controllerActionName = substr($existingMethodName, 0, -6);
break;
}
}
}
}
return $this->controllerActionName;
}
current work around:
Use only one-name-actions with no upper-case-character
The usage of ‘lcfirst’ instead of ‘strtoLower’ would allow a lowerCaseWriting. You must extend although the allcocation of $this->controllerActionName to prevent error because of misspelling (untested version)
public function getControllerActionName()
{
$controllerObjectName = $this->getControllerObjectName();
if ($controllerObjectName !== '' && $this->controllerActionName === lcfirst($this->controllerActionName)) {
$actionMethodName = $this->controllerActionName . 'Action';
$classMethods = get_class_methods($controllerObjectName);
if (is_array($classMethods)) {
foreach ($classMethods as $existingMethodName) {
if (lcfirst($existingMethodName) === lcfirst($actionMethodName)) {
$this->controllerActionName = lcfirst(substr($existingMethodName, 0, -6));
break;
}
}
}
}
return $this->controllerActionName;
}
I Think, the better way would be to throw an exception to announce the misconfiguration.
untested version
/**
* Returns the name of the action the controller is supposed to execute.
*
* @throws Exception\InvalidArgumentNameException
* @return string Action name
* @api
*/
public function getControllerActionName()
{
$controllerObjectName = $this->getControllerObjectName();
if ($controllerObjectName !== '') {
if ($this->controllerActionName === lcfirst($this->controllerActionName)) {
throw new \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException('No lowerCamelCase for action in request or configuration.', 58976458767);
}
$actionMethodName = $this->controllerActionName . 'Action';
$classMethods = get_class_methods($controllerObjectName);
if (is_array($classMethods)) {
foreach ($classMethods as $existingMethodName) {
if ($existingMethodName === lcfirst($existingMethodName)) {
throw new \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException('No lowerCamelCase for action in request or configuration.', 58976458767);
}
if ($existingMethodName === $actionMethodName) {
$this->controllerActionName = substr($existingMethodName, 0, -6);
break;
}
}
}
}
return $this->controllerActionName;
}Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.