Allow multiple "AsMessageHandler" attributes
This commit is contained in:
parent
dc00f8b7d6
commit
df4d3b5fa9
1 changed files with 19 additions and 16 deletions
|
@ -54,8 +54,9 @@ class HandlersLocatorFactory
|
||||||
$asHandlerClasses = $this->reflectionService
|
$asHandlerClasses = $this->reflectionService
|
||||||
->getClassNamesByAnnotation(AsMessageHandler::class);
|
->getClassNamesByAnnotation(AsMessageHandler::class);
|
||||||
foreach ($asHandlerClasses as $asHandlerClass) {
|
foreach ($asHandlerClasses as $asHandlerClass) {
|
||||||
/** @var AsMessageHandler $annotation */
|
/** @var AsMessageHandler[] $annotations */
|
||||||
$annotation = $this->reflectionService->getClassAnnotation($asHandlerClass, AsMessageHandler::class);
|
$annotations = $this->reflectionService->getClassAnnotations($asHandlerClass, AsMessageHandler::class);
|
||||||
|
foreach ($annotations as $annotation) {
|
||||||
$config['from_transport'] = $annotation->fromTransport;
|
$config['from_transport'] = $annotation->fromTransport;
|
||||||
$config['priority'] = $annotation->priority;
|
$config['priority'] = $annotation->priority;
|
||||||
$method = $annotation->method ?? '__invoke';
|
$method = $annotation->method ?? '__invoke';
|
||||||
|
@ -67,11 +68,13 @@ class HandlersLocatorFactory
|
||||||
if ($annotation->bus !== null && $annotation->bus !== $busName) {
|
if ($annotation->bus !== null && $annotation->bus !== $busName) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
$handler = $this->objectManager->get($asHandlerClass);
|
||||||
$handlerDescriptors[$messageName][] = new HandlerDescriptor(
|
$handlerDescriptors[$messageName][] = new HandlerDescriptor(
|
||||||
$this->objectManager->get($asHandlerClass),
|
$this->objectManager->get($asHandlerClass),
|
||||||
$config
|
$config
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// TODO: Maybe we can allow handlers to be added to bus or globally by configuration?
|
// TODO: Maybe we can allow handlers to be added to bus or globally by configuration?
|
||||||
|
|
||||||
return new HandlersLocator($handlerDescriptors);
|
return new HandlersLocator($handlerDescriptors);
|
||||||
|
|
Loading…
Reference in a new issue