-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Add a MessageHandlerInterface
(multiple messages + auto-configuration)
#26685
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Messenger\Handler; | ||
|
||
/** | ||
* Handlers can implement this interface. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should say this is a marker interface somehow. Basically so it’s a bit more clear if you look in the interface, why it exists. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nicolas-grekas had an opposite argument last time, so I suggest that we don't necessarily explicit why it's here (unless we have a lot of questions and then add it 👍) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I commented that we should not tell about "autoconfiguration", which isn't the incompatible with Ryan's comment :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sroze Can you add some more information here then? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👀 #26786 |
||
* | ||
* @author Samuel Roze <samuel.roze@gmail.com> | ||
*/ | ||
interface MessageHandlerInterface | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Messenger\Handler; | ||
|
||
/** | ||
* Handlers can implement this interface to handle multiple messages. | ||
* | ||
* @author Samuel Roze <samuel.roze@gmail.com> | ||
*/ | ||
interface MessageSubscriberInterface extends MessageHandlerInterface | ||
{ | ||
/** | ||
* Return a list of messages to be handled. | ||
* | ||
* It returns a list of messages like in the following example: | ||
* | ||
* return [MyMessage::class]; | ||
* | ||
* It can also change the priority per classes. | ||
* | ||
* return [ | ||
* [FirstMessage::class, 0], | ||
* [SecondMessage::class, -10], | ||
* ]; | ||
* | ||
* The `__invoke` method of the handler will be called as usual with the message to handle. | ||
* | ||
* @return array | ||
*/ | ||
public static function getHandledMessages(): array; | ||
} |
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.
Are there two different but similar interfaces or is this a typo?
HandlerInterface
andMessageHandlerInterface
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.
That's definitely a typo while renaming
HandlerInterface
toMessageHandlerInterface
. Updated 👍