Skip to content
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

[Messenger] Document stamps in HandleTrait::handle #20851

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Changes from all commits
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
14 changes: 14 additions & 0 deletions messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2512,6 +2512,20 @@ wherever you need a query bus behavior instead of the ``MessageBusInterface``::
}
}

You also can also add stamps when handling a message. For example, you can
add an ``DoctrineFlushStamp`` to flush the entity manager after handling the message::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stamp doss not exists in the symfony core maybe we should alternative or describe it as MyCustomStamp.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I'll take a look at it later today 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Alexander! I wasn't aware of this.

We updated the example directly in 7f9f20f but if you think this needs further changes, please create a Pull Request. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @javiereguiluz 👍


$this->handle(new SomeMessage($data), [new DoctrineFlushStamp()]);

.. note::

If adding a stamp of the same type that already exists in the envelope,
both stamps will be kept (see `Envelopes & Stamps`_).

.. versionadded:: 7.3

The ``$stamps`` parameter on the handle method was introduced in Symfony 7.3.

Customizing Handlers
--------------------

Expand Down