Skip to content

Commit 14c277c

Browse files
MichaelaBlatakovaf3l1x
authored andcommitted
Fix: fixed support for AsCommand aliases
1 parent dc2b84f commit 14c277c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/DI/ConsoleExtension.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ public function beforeCompile(): void
157157
}
158158
}
159159

160+
$aliases = [];
160161
// Try to detect command name from Command::getDefaultName()
161162
if ($commandName === null) {
162163
$commandName = call_user_func([$service->getType(), 'getDefaultName']); // @phpstan-ignore-line
@@ -168,10 +169,19 @@ public function beforeCompile(): void
168169
)
169170
);
170171
}
172+
$aliases = explode('|', $commandName);
173+
$commandName = array_shift($aliases);
174+
if ($commandName === '') {
175+
$commandName = array_shift($aliases);
176+
}
171177
}
172178

173179
// Append service to command map
174180
$commandMap[$commandName] = $serviceName;
181+
182+
foreach ($aliases as $alias) {
183+
$commandMap[$alias] = $serviceName;
184+
}
175185
}
176186

177187
/** @var ServiceDefinition $commandLoaderDef */

0 commit comments

Comments
 (0)