Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #26685 [Messenger] Add a
MessageHandlerInterface
(multiple …
…messages + auto-configuration) (sroze) This PR was squashed before being merged into the 4.1-dev branch (closes #26685). Discussion ---------- [Messenger] Add a `MessageHandlerInterface` (multiple messages + auto-configuration) | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ø | License | MIT | Doc PR | ø Based on @chalasr's PR: #26672. This reduces the hassle of registering handlers: it allows the auto-configuration with a new interface `HandlerInterface`. At the same time, it allows a handler to handle multiple messages. Commits ------- 07e6bc7 [Messenger] Add a `MessageHandlerInterface` (multiple messages + auto-configuration)
- Loading branch information
Showing
5 changed files
with
194 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Symfony/Component/Messenger/Handler/MessageHandlerInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
* | ||
* @author Samuel Roze <samuel.roze@gmail.com> | ||
*/ | ||
interface MessageHandlerInterface | ||
{ | ||
} |
40 changes: 40 additions & 0 deletions
40
src/Symfony/Component/Messenger/Handler/MessageSubscriberInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters