Skip to content

[Messenger] Add documentation for allow_no_senders #17383

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 1 commit into from
Oct 21, 2022
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
22 changes: 18 additions & 4 deletions messenger/multiple_buses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ an **event bus**. The event bus could have zero or more subscribers.
event.bus:
# the 'allow_no_handlers' middleware allows to have no handler
# configured for this bus without throwing an exception
default_middleware: allow_no_handlers
# the 'allow_no_senders' middleware allows to have no sender
# configured for this bus without throwing an exception
default_middleware:
enabled: true
allow_no_handlers: false
allow_no_senders: true
middleware:
- validation

Expand Down Expand Up @@ -64,7 +69,10 @@ an **event bus**. The event bus could have zero or more subscribers.
</framework:bus>
<!-- the 'allow_no_handlers' middleware allows to have no handler
configured for this bus without throwing an exception -->
<framework:bus name="event.bus" default-middleware="allow_no_handlers">
<!-- the 'allow_no_senders' middleware allows to have no sender
configured for this bus without throwing an exception -->
<framework:bus name="event.bus">
<framework:default-middleware enabled="true" allow_no_handlers="false" allow_no_senders="true"/>
<framework:middleware id="validation"/>
</framework:bus>
</framework:messenger>
Expand All @@ -88,9 +96,15 @@ an **event bus**. The event bus could have zero or more subscribers.
$queryBus->middleware()->id('validation');

$eventBus = $framework->messenger()->bus('event.bus');
// the 'allow_no_handlers' middleware allows to have no handler
// the 'allowNoHandlers' middleware allows to have no handler
// configured for this bus without throwing an exception
// the 'allowNoSenders' middleware allows to have no sender
// configured for this bus without throwing an exception
$eventBus->defaultMiddleware('allow_no_handlers');
$eventBus->defaultMiddleware()
->enabled(true)
->allowNoHandlers(false)
->allowNoSenders(true)
;
$eventBus->middleware()->id('validation');
};

Expand Down