public function addShortPluginAliases()
{
$plugins = Plugin::loaded();
$io = new ConsoleIo();
$task = new CommandTask($io);
$io->setLoggers(false);
$list = $task->getShellList() + ['app' => []];
$fixed = array_flip($list['app']) + array_flip($list['CORE']);
$aliases = $others = [];
foreach ($plugins as $plugin) {
if (!isset($list[$plugin])) {
continue;
}
foreach ($list[$plugin] as $shell) {
$aliases += [$shell => $plugin];
if (!isset($others[$shell])) {
$others[$shell] = [$plugin];
} else {
$others[$shell] = array_merge($others[$shell], [$plugin]);
}
}
}
foreach ($aliases as $shell => $plugin) {
if (isset($fixed[$shell])) {
Log::write('debug', "command '{$shell}' in plugin '{$plugin}' was not aliased, conflicts with another shell", ['shell-dispatcher']);
continue;
}
$other = static::alias($shell);
if ($other) {
$other = $aliases[$shell];
if ($other !== $plugin) {
Log::write('debug', "command '{$shell}' in plugin '{$plugin}' was not aliased, conflicts with '{$other}'", ['shell-dispatcher']);
}
continue;
}
if (isset($others[$shell])) {
$conflicts = array_diff($others[$shell], [$plugin]);
if (count($conflicts) > 0) {
$conflictList = implode("', '", $conflicts);
Log::write('debug', "command '{$shell}' in plugin '{$plugin}' was not aliased, conflicts with '{$conflictList}'", ['shell-dispatcher']);
}
}
static::alias($shell, "{$plugin}.{$shell}");
}
return static::$_aliases;
}