8000 [Messenger] Add the Envelope in the documentation by sroze · Pull Request #9757 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content
8000

[Messenger] Add the Envelope in the documentation #9757

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

Merged
merged 4 commits into from
Jul 12, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Renaming variable
  • Loading branch information
weaverryan authored Jul 12, 2018
commit a87d727d53295bf1770def8c103551afb69b1355
15 changes: 7 additions & 8 deletions components/messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,26 +131,25 @@ marker, like this::

class MyOwnMiddleware implements MiddlewareInterface, EnvelopeAwareInterface
{
public function handle($message, callable $next)
public function handle($envelope, callable $next)
{
// $message here is an `Envelope` object, because this middleware
// $envelope here is an `Envelope` object, because this middleware
// implements the EnvelopeAwareInterface interface.

if (null !== $message->get(ReceivedMessage::class)) {
if (null !== $envelope->get(ReceivedMessage::class)) {
// Message just has been received...

// You could for example add another item.
$message = $message->with(new AnotherEnvelopeItem(/* ... */));
$envelope = $envelope->with(new AnotherEnvelopeItem(/* ... */));
}

return $next($message);
return $next($envelope);
}
}

The above example will forward the message to the next middleware with an additional
envelope item if the message has just been received (i.e. has the `ReceivedMessage` item).
You can create your own items by implementing the :class:`Symfony\\Component\\Messenger\\EnvelopeAwareInterface`
interface.
envelope item *if* the message has just been received (i.e. has the `ReceivedMessage` item).
You can create your own items by implementing :class:`Symfony\\Component\\Messenger\\EnvelopeAwareInterface`.

Transports
----------
Expand Down
0