File tree 1 file changed +8
-14
lines changed
Filter options
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
208
208
required for your service container to be created. When using multiple buses, by default,
209
209
the auto-wiring will not work as it won't know why bus to inject in your own services.
210
210
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:
224
213
225
214
.. code-block :: yaml
226
215
227
216
# config/services.yaml
228
217
services :
229
- App\CommandBus : ['@messenger.bus.commands']
218
+ _defaults :
219
+ # ...
220
+
221
+ bind :
222
+ $commandBus : ' @messenger.bus.commands'
223
+ $eventBus : ' @messenger.bus.events'
230
224
231
225
Middleware
232
226
----------
You can’t perform that action at this time.
0 commit comments