2 namespace TYPO3\CMS\Extbase\Mvc\Cli;
55 if ($this->availableCommands === null) {
56 $this->availableCommands = array();
57 $commandControllerClassNames = is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'extbase'][
'commandControllers']) ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'extbase'][
'commandControllers'] : array();
58 foreach ($commandControllerClassNames as $className) {
59 if (!class_exists($className)) {
62 foreach (get_class_methods($className) as $methodName) {
63 if (substr($methodName, -7, 7) ===
'Command') {
64 $this->availableCommands[] = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Cli\Command::class, $className, substr($methodName, 0, -7));
85 $commandIdentifier = strtolower(trim($commandIdentifier));
86 if ($commandIdentifier ===
'help') {
87 $commandIdentifier =
'extbase:help:help';
89 $matchedCommands = array();
93 $matchedCommands[] = $command;
96 if (empty($matchedCommands)) {
97 throw new \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchCommandException(
'No command could be found that matches the command identifier "' . $commandIdentifier .
'".', 1310556663);
99 if (count($matchedCommands) > 1) {
100 throw new \TYPO3\CMS\Extbase\Mvc\Exception\AmbiguousCommandIdentifierException(
'More than one command matches the command identifier "' . $commandIdentifier .
'"', 1310557169, null, $matchedCommands);
102 return current($matchedCommands);
131 if ($this->shortCommandIdentifiers === null) {
132 $commandsByCommandName = array();
134 list($extensionKey, $controllerName, $commandName) = explode(
':', $availableCommand->getCommandIdentifier());
135 if (!isset($commandsByCommandName[$commandName])) {
136 $commandsByCommandName[$commandName] = array();
138 if (!isset($commandsByCommandName[$commandName][$controllerName])) {
139 $commandsByCommandName[$commandName][$controllerName] = array();
141 $commandsByCommandName[$commandName][$controllerName][] = $extensionKey;
144 list($extensionKey, $controllerName, $commandName) = explode(
':', $availableCommand->getCommandIdentifier());
145 if (count($commandsByCommandName[$commandName][$controllerName]) > 1) {
146 $this->shortCommandIdentifiers[$availableCommand->getCommandIdentifier()] = sprintf(
'%s:%s:%s', $extensionKey, $controllerName, $commandName);
148 $this->shortCommandIdentifiers[$availableCommand->getCommandIdentifier()] = sprintf(
'%s:%s', $controllerName, $commandName);
166 $searchedCommandIdentifierParts = explode(
':', $commandIdentifier);
167 $extensionKey = array_shift($commandIdentifierParts);
168 if (count($searchedCommandIdentifierParts) === 3) {
169 $searchedExtensionKey = array_shift($searchedCommandIdentifierParts);
170 if ($searchedExtensionKey !== $extensionKey) {
174 if (count($searchedCommandIdentifierParts) !== 2) {
177 return $searchedCommandIdentifierParts === $commandIdentifierParts;