@@ -24,16 +24,16 @@ an **event bus**. The event bus could have zero or more subscribers.
24
24
framework :
25
25
messenger :
26
26
# The bus that is going to be injected when injecting MessageBusInterface
27
- default_bus : messenger .bus.commands
27
+ default_bus : command .bus
28
28
buses :
29
- messenger .bus.commands :
29
+ command .bus :
30
30
middleware :
31
31
- validation
32
32
- doctrine_transaction
33
- messenger .bus.queries :
33
+ query .bus :
34
34
middleware :
35
35
- validation
36
- messenger .bus.events :
36
+ event .bus :
37
37
default_middleware : allow_no_handlers
38
38
middleware :
39
39
- validation
@@ -52,15 +52,15 @@ an **event bus**. The event bus could have zero or more subscribers.
52
52
53
53
<framework : config >
54
54
<!-- The bus that is going to be injected when injecting MessageBusInterface -->
55
- <framework : messenger default-bus =" messenger .bus.commands " >
56
- <framework : bus name =" messenger .bus.commands " >
55
+ <framework : messenger default-bus =" command .bus" >
56
+ <framework : bus name =" command .bus" >
57
57
<framework : middleware id =" validation" />
58
58
<framework : middleware id =" doctrine_transaction" />
59
59
<framework : bus >
60
- <framework : bus name =" messenger .bus.queries " >
60
+ <framework : bus name =" query .bus" >
61
61
<framework : middleware id =" validation" />
62
62
<framework : bus >
63
- <framework : bus name =" messenger .bus.events " default-middleware =" allow_no_handlers" >
63
+ <framework : bus name =" event .bus" default-middleware =" allow_no_handlers" >
64
64
<framework : middleware id =" validation" />
65
65
<framework : bus >
66
66
</framework : messenger >
@@ -73,20 +73,20 @@ an **event bus**. The event bus could have zero or more subscribers.
73
73
$container->loadFromExtension('framework', [
74
74
'messenger' => [
75
75
// The bus that is going to be injected when injecting MessageBusInterface
76
- 'default_bus' => 'messenger .bus.commands ',
76
+ 'default_bus' => 'command .bus',
77
77
'buses' => [
78
- 'messenger .bus.commands ' => [
78
+ 'command .bus' => [
79
79
'middleware' => [
80
80
'validation',
81
81
'doctrine_transaction',
82
82
],
83
83
],
84
- 'messenger .bus.queries ' => [
84
+ 'query .bus' => [
85
85
'middleware' => [
86
86
'validation',
87
87
],
88
88
],
89
- 'messenger .bus.events ' => [
89
+ 'event .bus' => [
90
90
'default_middleware' => 'allow_no_handlers',
91
91
'middleware' => [
92
92
'validation',
@@ -98,62 +98,12 @@ an **event bus**. The event bus could have zero or more subscribers.
98
98
99
99
This will create three new services:
100
100
101
- * ``messenger .bus.commands ``: autowireable with the :class: `Symfony\\ Component\\ Messenger\\ MessageBusInterface `
101
+ * ``command .bus ``: autowireable with the :class: `Symfony\\ Component\\ Messenger\\ MessageBusInterface `
102
102
type-hint (because this is the ``default_bus ``);
103
103
104
- * ``messenger .bus.queries ``: autowireable with the ``MessageBusInterface $messengerBusQueries ``;
104
+ * ``query .bus ``: autowireable with ``MessageBusInterface $queryBus ``;
105
105
106
- * ``messenger.bus.events ``: autowireable with the ``MessageBusInterface $messengerBusEvents ``.
107
-
108
- Type-hints and Auto-wiring
109
- --------------------------
110
-
111
- Auto-wiring is a great feature that allows you to reduce the amount of configuration
112
- required for your service container to be created. By using ``MessageBusInterface ``
113
- as argument type-hint in your services, the default configured bus will be injected
114
- (i.e ``messenger.bus.commands `` in above examples).
115
-
116
- When working with multiple buses, you can use the ``DependencyInjection `` component's
117
- binding capabilities to clarify which bus will be injected based on the argument's name:
118
-
119
- .. configuration-block ::
120
-
121
- .. code-block :: yaml
122
-
123
- # config/services.yaml
124
- services :
125
- _defaults :
126
- # ...
127
-
128
- bind :
129
- $commandBus : ' @messenger.bus.commands'
130
- $queryBus : ' @messenger.bus.queries'
131
- $eventBus : ' @messenger.bus.events'
132
-
133
- .. code-block :: xml
134
-
135
- <!-- config/services.xml -->
136
- <?xml version =" 1.0" encoding =" UTF-8" ?>
137
- <container xmlns =" http://symfony.com/schema/dic/services"
138
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
139
- xsi : schemaLocation =" http://symfony.com/schema/dic/services
140
- https://symfony.com/schema/dic/services/services-1.0.xsd" >
141
-
142
- <services >
143
- <defaults >
144
- <bind key =" $commandBus" type =" service" id =" messenger.bus.commands" />
145
- <bind key =" $queryBus" type =" service" id =" messenger.bus.queries" />
146
- <bind key =" $eventBus" type =" service" id =" messenger.bus.events" />
147
- </defaults >
148
- </services >
149
- </container >
150
-
151
- .. code-block :: php
152
-
153
- // config/services.php
154
- $container->bind('$commandBus', 'messenger.bus.commands');
155
- $container->bind('$queryBus', 'messenger.bus.queries');
156
- $container->bind('$eventBus', 'messenger.bus.events');
106
+ * ``event.bus ``: autowireable with ``MessageBusInterface $eventBus ``.
157
107
158
108
Restrict Handlers per Bus
159
109
-------------------------
0 commit comments