8000 Update the example of using multiple buses to use DI's `bind`s · symfony/symfony-docs@9b7b85f · GitHub
[go: up one dir, main page]

Skip to content
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 files
srozeweaverryan
authored andcommitted
Update the example of using multiple buses to use DI's binds
1 parent c76b2c2 commit 9b7b85f

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

messenger.rst

Lines 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