minor #29366 [Messenger] Mention HandleTrait in UPGRADE-4.2.md file (ogizanagi)
This PR was merged into the 4.2 branch.
Discussion
----------
[Messenger] Mention HandleTrait in UPGRADE-4.2.md file
| Q | A
| ------------- | ---
| Branch? | 4.2 <!-- see below -->
| Bug fix? | no
| New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | N/A <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | N/A
Mentions this trait as a solution to build query buses.
I've removed the callable suggestion, as I suspect this won't be the most useful one.
Commits
-------
3cd4477563
[Messenger] Mention HandleTrait in UPGRADE-4.2.md file
This commit is contained in:
commit
4ea6f649dc
@ -199,7 +199,10 @@ Messenger
|
|||||||
---------
|
---------
|
||||||
|
|
||||||
* The `MiddlewareInterface::handle()` and `SenderInterface::send()` methods must now return an `Envelope` instance.
|
* The `MiddlewareInterface::handle()` and `SenderInterface::send()` methods must now return an `Envelope` instance.
|
||||||
* The return value of handlers is ignored. If you used to return a value, e.g in query bus handlers, you can either:
|
* The return value of handlers isn't forwarded anymore by middleware and buses.
|
||||||
|
If you used to return a value, e.g in query bus handlers, you can either:
|
||||||
|
- get the result from the `HandledStamp` in the envelope returned by the bus.
|
||||||
|
- use the `HandleTrait` to leverage a message bus, expecting a single, synchronous message handling and returning its result.
|
||||||
- make your `Query` mutable to allow setting & getting a result:
|
- make your `Query` mutable to allow setting & getting a result:
|
||||||
```php
|
```php
|
||||||
// When dispatching:
|
// When dispatching:
|
||||||
@ -209,15 +212,6 @@ Messenger
|
|||||||
// In your handler:
|
// In your handler:
|
||||||
$query->setResult($yourResult);
|
$query->setResult($yourResult);
|
||||||
```
|
```
|
||||||
- define a callable on your `Query` to be called in your handler:
|
|
||||||
```php
|
|
||||||
// When dispatching:
|
|
||||||
$bus->dispatch(new Query([$this, 'onResult']));
|
|
||||||
|
|
||||||
// In your handler:
|
|
||||||
$query->executeCallback($yourResult);
|
|
||||||
```
|
|
||||||
|
|
||||||
* The `EnvelopeAwareInterface` was removed and the `MiddlewareInterface::handle()` method now requires an `Envelope` object
|
* The `EnvelopeAwareInterface` was removed and the `MiddlewareInterface::handle()` method now requires an `Envelope` object
|
||||||
as first argument. When using built-in middleware with the provided `MessageBus`, you will not have to do anything.
|
as first argument. When using built-in middleware with the provided `MessageBus`, you will not have to do anything.
|
||||||
If you use your own `MessageBusInterface` implementation, you must wrap the message in an `Envelope` before passing it to middleware.
|
If you use your own `MessageBusInterface` implementation, you must wrap the message in an `Envelope` before passing it to middleware.
|
||||||
|
Reference in New Issue
Block a user