Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9b7b85f

Browse filesBrowse files
srozeweaverryan
authored andcommitted
Update the example of using multiple buses to use DI's binds
1 parent c76b2c2 commit 9b7b85f
Copy full SHA for 9b7b85f

File tree

1 file changed

+8
-14
lines changed
Filter options

1 file changed

+8
-14
lines changed

‎messenger.rst

Copy file name to clipboardExpand all lines: messenger.rst
+8-14Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -208,25 +208,19 @@ Auto-wiring is a great feature that allows you to reduce the amount of configura
208208
required for your service container to be created. When using multiple buses, by default,
209209
the auto-wiring will not work as it won't know why bus to inject in your own services.
210210

211-
In order to clarify this, you will have to create your own decorators for your message
212-
buses. Let's create one for your ``CommandBus``::
213-
214-
namespace App;
215-
216-
use Symfony\Component\Messenger\AbstractMessageBusDecorator;
217-
218-
final class CommandBus extends AbstractMessageBusDecorator
219-
{
220-
}
221-
222-
Last step is to register your service (and explicit its argument) to be able to typehint
223-
your ``CommandBus`` in your services:
211+
In order to clarify this, you can use the DependencyInjection's binding capabilities
212+
to clarify which bus will be injected based on the argument's name:
224213

225214
.. code-block:: yaml
226215
227216
# config/services.yaml
228217
services:
229-
App\CommandBus: ['@messenger.bus.commands']
218+
_defaults:
219+
# ...
220+
221+
bind:
222+
$commandBus: '@messenger.bus.commands'
223+
$eventBus: '@messenger.bus.events'
230224
231225
Middleware
232226
----------

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.