Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the same pattern for command controller namespaces as the core #565

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions Classes/Mvc/Cli/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,22 @@ public function __construct($controllerClassName, $controllerCommandName)
unset($classNameParts[1]);
$classNameParts = array_values($classNameParts);
}
if (count($classNameParts) !== 4 || strpos($classNameParts[3], 'CommandController') === false) {
$numberOfClassNameParts = count($classNameParts);
if ($numberOfClassNameParts < 3) {
throw new \InvalidArgumentException(
'Invalid controller class name "' . $controllerClassName . '". Class name must have exactly 4 parts and must end with "CommandController" (e.g. Vendor\ExtensionName\Command\MySimpleCommandController).',
'Controller class names must at least consist of three parts: vendor, extension name and path.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vendor, extension name and path

vendor, extension name and command controller name

1438782187
);
}
if (strpos($classNameParts[$numberOfClassNameParts - 1], 'CommandController') === false) {
throw new \InvalidArgumentException(
'Invalid controller class name "' . $controllerClassName . '". Class name must end with "CommandController" (e.g. Vendor\ExtensionName\Command\MySimpleCommandController).',
1305100019
);
}
$this->extensionName = $classNameParts[1];
$extensionKey = \TYPO3\CMS\Core\Utility\GeneralUtility::camelCaseToLowerCaseUnderscored($this->extensionName);
$this->commandIdentifier = strtolower($extensionKey . ':' . substr($classNameParts[3], 0, -17) . ':' . $controllerCommandName);
$this->commandIdentifier = strtolower($extensionKey . ':' . substr($classNameParts[$numberOfClassNameParts - 1], 0, -17) . ':' . $controllerCommandName);
}

/**
Expand Down