mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 03:37:44 +08:00
Fixed the error when register multi AsCommand (#6593)
This commit is contained in:
parent
0e7435db45
commit
052cce3114
@ -7,6 +7,10 @@
|
||||
- [#6579](https://github.com/hyperf/hyperf/pull/6579) Added `now()` and `today()` helper functions.
|
||||
- [#6590](https://github.com/hyperf/hyperf/pull/6590) Added `--graceful` to migrateCommand.
|
||||
|
||||
## Fixed
|
||||
|
||||
- [#6593](https://github.com/hyperf/hyperf/pull/6593) Fixed the error when register multi `AsCommand`.
|
||||
|
||||
# v3.1.12 - 2024-03-07
|
||||
|
||||
## Fixed
|
||||
|
@ -72,24 +72,28 @@ class RegisterCommandListener implements ListenerInterface
|
||||
$commands = AnnotationCollector::getMethodsByAnnotation(AsCommandAnnotation::class);
|
||||
|
||||
foreach ($commands as $metadata) {
|
||||
/** @var AsCommandAnnotation $annotation */
|
||||
$annotation = $metadata['annotation'];
|
||||
$command = new AsCommand(
|
||||
$this->container,
|
||||
$annotation->signature,
|
||||
$metadata['class'],
|
||||
$metadata['method'],
|
||||
);
|
||||
/** @var \Hyperf\Di\Annotation\MultipleAnnotation $multiAnnotation */
|
||||
$multiAnnotation = $metadata['annotation'];
|
||||
/** @var AsCommandAnnotation[] $annotations */
|
||||
$annotations = $multiAnnotation->toAnnotations();
|
||||
foreach ($annotations as $annotation) {
|
||||
$command = new AsCommand(
|
||||
$this->container,
|
||||
$annotation->signature,
|
||||
$metadata['class'],
|
||||
$metadata['method'],
|
||||
);
|
||||
|
||||
if ($annotation->description) {
|
||||
$command->setDescription($annotation->description);
|
||||
}
|
||||
if ($annotation->aliases) {
|
||||
$command->setAliases($annotation->aliases);
|
||||
}
|
||||
if ($annotation->description) {
|
||||
$command->setDescription($annotation->description);
|
||||
}
|
||||
if ($annotation->aliases) {
|
||||
$command->setAliases($annotation->aliases);
|
||||
}
|
||||
|
||||
$this->container->set($annotation->id, $command);
|
||||
$this->appendConfig('commands', $annotation->id);
|
||||
$this->container->set($annotation->id, $command);
|
||||
$this->appendConfig('commands', $annotation->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user