95 $this->controllerCommandMethod = $this->controllerCommandName .
'Command';
97 if (isset($classNameParts[0]) && $classNameParts[0] ===
'TYPO3' && isset($classNameParts[1]) && $classNameParts[1] ===
'CMS') {
98 $classNameParts[0] .=
'\\' . $classNameParts[1];
99 unset($classNameParts[1]);
100 $classNameParts = array_values($classNameParts);
102 $numberOfClassNameParts = count($classNameParts);
103 if ($numberOfClassNameParts < 3) {
104 throw new \InvalidArgumentException(
105 'Controller class names must at least consist of three parts: vendor, extension name and path.',
109 if (strpos($classNameParts[$numberOfClassNameParts - 1],
'CommandController') ===
false) {
110 throw new \InvalidArgumentException(
111 'Invalid controller class name "' .
$controllerClassName .
'". Class name must end with "CommandController".',
116 $this->extensionName = $classNameParts[1];
117 $extensionKey = \TYPO3\CMS\Core\Utility\GeneralUtility::camelCaseToLowerCaseUnderscored($this->extensionName);
118 $this->commandIdentifier = strtolower($extensionKey .
':' . substr($classNameParts[$numberOfClassNameParts - 1], 0, -17) .
':' .
$controllerCommandName);
123 $this->classSchema = $this->reflectionService->getClassSchema($this->controllerClassName);
169 $lines = explode(LF, $this->classSchema->getMethod($this->controllerCommandMethod)[
'description']);
170 return !empty($lines) ? trim($lines[0]) :
'<no description available>';
182 $lines = explode(LF, $this->classSchema->getMethod($this->controllerCommandMethod)[
'description']);
184 $descriptionLines = [];
185 foreach ($lines as $line) {
186 $trimmedLine = trim($line);
187 if ($descriptionLines !== [] || $trimmedLine !==
'') {
188 $descriptionLines[] = $trimmedLine;
191 return implode(LF, $descriptionLines);
201 return !empty($this->classSchema->getMethod($this->controllerCommandMethod)[
'params']);
216 $commandArgumentDefinitions = [];
217 $commandParameters = $this->classSchema->getMethod($this->controllerCommandMethod)[
'params'];
218 $commandParameterTags = $this->classSchema->getMethod($this->controllerCommandMethod)[
'tags'][
'param'];
220 foreach ($commandParameters as $commandParameterName => $commandParameterDefinition) {
221 $explodedAnnotation = preg_split(
'/\s+/', $commandParameterTags[$i], 3);
222 $description = !empty($explodedAnnotation[2]) ? $explodedAnnotation[2] :
'';
223 $required = $commandParameterDefinition[
'optional'] !==
true;
224 $commandArgumentDefinitions[] = $this->objectManager->get(\
TYPO3\CMS\
Extbase\Mvc\Cli\CommandArgumentDefinition::class, $commandParameterName, $required, $description);
227 return $commandArgumentDefinitions;
239 return isset($this->classSchema->getMethod($this->controllerCommandMethod)[
'tags'][
'internal']);
249 return isset($this->classSchema->getMethod($this->controllerCommandMethod)[
'tags'][
'cli']);
264 'Method isFlushingCaches() will be removed in TYPO3 v10.0. Do not call from other extension.',
267 return isset($this->classSchema->getMethod($this->controllerCommandMethod)[
'tags'][
'flushesCaches']);
278 if (!isset($this->classSchema->getMethod($this->controllerCommandMethod)[
'tags'][
'see'])) {
281 $relatedCommandIdentifiers = [];
282 foreach ($this->classSchema->getMethod($this->controllerCommandMethod)[
'tags'][
'see'] as $tagValue) {
283 if (preg_match(
'/^[\\w\\d\\.]+:[\\w\\d]+:[\\w\\d]+$/', $tagValue) === 1) {
284 $relatedCommandIdentifiers[] = $tagValue;
287 return $relatedCommandIdentifiers;