File tree Expand file tree Collapse file tree 1 file changed +8
-14
lines changed Expand file tree Collapse file tree 1 file changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -208,25 +208,19 @@ Auto-wiring is a great feature that allows you to reduce the amount of configura
208208required for your service container to be created. When using multiple buses, by default,
209209the 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----------
You can’t perform that action at this time.
0 commit comments