protected function getShortCommandIdentifiers()
{
if ($this->shortCommandIdentifiers === null) {
$commandsByCommandName = [];
/** @var Command $availableCommand */
foreach ($this->getAvailableCommands() as $availableCommand) {
list($packageKey, $controllerName, $commandName) = explode(':', $availableCommand->getCommandIdentifier());
if (!isset($commandsByCommandName[$commandName])) {
$commandsByCommandName[$commandName] = [];
}
if (!isset($commandsByCommandName[$commandName][$controllerName])) {
$commandsByCommandName[$commandName][$controllerName] = [];
}
$commandsByCommandName[$commandName][$controllerName][] = $packageKey;
}
foreach ($this->getAvailableCommands() as $availableCommand) {
list($packageKey, $controllerName, $commandName) = explode(':', $availableCommand->getCommandIdentifier());
if (count($commandsByCommandName[$commandName][$controllerName]) > 1 || $this->bootstrap->isCompiletimeCommand($availableCommand->getCommandIdentifier())) {
$packageKeyParts = array_reverse(explode('.', $packageKey));
for ($i = 1; $i <= count($packageKeyParts); $i++) {
$shortCommandIdentifier = implode('.', array_slice($packageKeyParts, 0, $i)) . ':' . $controllerName . ':' . $commandName;
try {
$this->getCommandByIdentifier($shortCommandIdentifier);
$this->shortCommandIdentifiers[$availableCommand->getCommandIdentifier()] = $shortCommandIdentifier;
break;
} catch (CommandException $exception) {
}
}
} else {
$this->shortCommandIdentifiers[$availableCommand->getCommandIdentifier()] = sprintf('%s:%s', $controllerName, $commandName);
}
}
}
return $this->shortCommandIdentifiers;
}