-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[WIP] [Messenger] Locate exactly one handler #40254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] [Messenger] Locate exactly one handler #40254
Conversation
$this->handlers = $handlers; | ||
} | ||
|
||
public function getHandlers(Envelope $envelope): iterable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need a dock-block?
/**
* {@inheritdoc}
*
* @throws NoHandlerForMessageException When no handler is found class
*/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll fix all CS if this feature gets interest. Thanks for pointing it out 👍
|
||
public function getHandlers(Envelope $envelope): iterable | ||
{ | ||
$type = \get_class($envelope->getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit pick: This variable is named $class is similar function. e.g. HandlersLocator.php line 69
{ | ||
$type = \get_class($envelope->getMessage()); | ||
if (!isset($this->handlers[$type])) { | ||
throw new NoHandlerForMessageException($type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8000Shouldn't the error message include the message type, rather that the type/class name
throw new NoHandlerForMessageException($this->handlers[$type]);
Theory being the error message 'Multiple handlers for message "%s"', thus, does this mean $envelope->getMessage()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this specific case, $type
holds the message type and $this->handlers[$type]
is not set.
Theory being the error message 'Multiple handlers for message "%s"', thus, does this mean $envelope->getMessage()?
I don't understand what you mean.
Superseded by #43300 |
Related to #36958
The main idea is to allow definition of a command bus which helps developper detect the following misconfigurations:
Today, only the first case can be detected (this is the default behaviour of the HandleMessageMiddleware), the second one is not (instead, all the command handlers will be called).