@@ -58,7 +58,7 @@ Most of the time, that's exactly what you want to do. But sometimes,
58
58
you might want to decorate the old one instead (i.e. apply the `Decorator pattern `_).
59
59
In this case, the old service should be kept around to be able to reference
60
60
it in the new one. This configuration replaces ``App\Mailer `` with a new one,
61
- but keeps a reference of the old one as ``App\DecoratingMailer .inner ``:
61
+ but keeps a reference of the old one as ``.inner ``:
62
62
63
63
.. configuration-block ::
64
64
@@ -70,7 +70,7 @@ but keeps a reference of the old one as ``App\DecoratingMailer.inner``:
70
70
71
71
App\DecoratingMailer :
72
72
# overrides the App\Mailer service
73
- # but that service is still available as App\DecoratingMailer .inner
73
+ # but that service is still available as " .inner"
74
74
decorates : App\Mailer
75
75
76
76
.. code-block :: xml
@@ -84,6 +84,8 @@ but keeps a reference of the old one as ``App\DecoratingMailer.inner``:
84
84
<services >
85
85
<service id =" App\Mailer" />
86
86
87
+ <!-- overrides the App\Mailer service
88
+ but that service is still available as ".inner" -->
87
89
<service id =" App\DecoratingMailer"
88
90
decorates =" App\Mailer"
89
91
/>
@@ -106,7 +108,7 @@ but keeps a reference of the old one as ``App\DecoratingMailer.inner``:
106
108
107
109
$services->set(DecoratingMailer::class)
108
110
// overrides the App\Mailer service
109
- // but that service is still available as App\DecoratingMailer .inner
111
+ // but that service is still available as " .inner"
110
112
->decorate(Mailer::class);
111
113
};
112
114
@@ -119,7 +121,7 @@ decorating service has one argument type-hinted with the decorated service class
119
121
If you are not using autowiring or the decorating service has more than one
120
122
constructor argument type-hinted with the decorated service class, you must
121
123
inject the decorated service explicitly (the ID of the decorated service is
122
- automatically changed to ``decorating_service_id + '.inner' ``):
124
+ automatically changed to ``'.inner' ``):
123
125
124
126
.. configuration-block ::
125
127
@@ -132,7 +134,7 @@ automatically changed to ``decorating_service_id + '.inner'``):
132
134
App\DecoratingMailer :
133
135
decorates : App\Mailer
134
136
# pass the old service as an argument
135
- arguments : ['@App\DecoratingMailer .inner']
137
+ arguments : ['@.inner']
136
138
137
139
.. code-block :: xml
138
140
@@ -148,7 +150,7 @@ automatically changed to ``decorating_service_id + '.inner'``):
148
150
<service id =" App\DecoratingMailer"
149
151
decorates =" App\Mailer"
150
152
>
151
- <argument type =" service" id =" App\DecoratingMailer .inner" />
153
+ <argument type =" service" id =" .inner" />
152
154
</service >
153
155
154
156
</services >
@@ -170,9 +172,13 @@ automatically changed to ``decorating_service_id + '.inner'``):
170
172
$services->set(DecoratingMailer::class)
171
173
->decorate(Mailer::class)
172
174
// pass the old service as an argument
173
- ->args([ref(DecoratingMailer::class. '.inner')]);
175
+ ->args([ref('.inner')]);
174
176
};
175
177
178
+ .. versionadded :: 5.1
179
+
180
+ The special ``.inner `` value was introduced in Symfony 5.1. In previous
181
+ versions you needed to use: ``decorating_service_id + '.inner' ``.
176
182
177
183
.. tip ::
178
184
@@ -256,12 +262,12 @@ the ``decoration_priority`` option. Its value is an integer that defaults to
256
262
Bar :
257
263
decorates : Foo
258
264
decoration_priority : 5
259
- arguments : ['@Bar .inner']
265
+ arguments : ['@.inner']
260
266
261
267
Baz :
262
268
decorates : Foo
263
269
decoration_priority : 1
264
- arguments : ['@Baz .inner']
270
+ arguments : ['@.inner']
265
271
266
272
.. code-block :: xml
267
273
@@ -276,11 +282,11 @@ the ``decoration_priority`` option. Its value is an integer that defaults to
276
282
<service id =" Foo" />
277
283
278
284
<service id =" Bar" decorates =" Foo" decoration-priority =" 5" >
279
- <argument type =" service" id =" Bar .inner" />
285
+ <argument type =" service" id =" .inner" />
280
286
</service >
281
287
282
288
<service id =" Baz" decorates =" Foo" decoration-priority =" 1" >
283
- <argument type =" service" id =" Baz .inner" />
289
+ <argument type =" service" id =" .inner" />
284
290
</service >
285
291
</services >
286
292
</container >
@@ -297,11 +303,11 @@ the ``decoration_priority`` option. Its value is an integer that defaults to
297
303
298
304
$services->set(Bar::class)
299
305
->decorate(Foo::class, null, 5)
300
- ->args([ref(Bar::class. '.inner')]);
306
+ ->args([ref('.inner')]);
301
307
302
308
$services->set(Baz::class)
303
309
->decorate(Foo::class, null, 1)
304
- ->args([ref(Baz::class. '.inner')]);
310
+ ->args([ref('.inner')]);
305
311
};
306
312
307
313
@@ -331,7 +337,7 @@ Three different behaviors are available:
331
337
Bar :
332
338
decorates : Foo
333
339
decoration_on_invalid : ignore
334
- arguments : ['@Bar .inner']
340
+ arguments : ['@.inner']
335
341
336
342
.. code-block :: xml
337
343
@@ -346,7 +352,7 @@ Three different behaviors are available:
346
352
<service id =" Foo" />
347
353
348
354
<service id =" Bar" decorates =" Foo" decoration-on-invalid =" ignore" >
349
- <argument type =" service" id =" Bar .inner" />
355
+ <argument type =" service" id =" .inner" />
350
356
</service >
351
357
</services >
352
358
</container >
@@ -365,7 +371,7 @@ Three different behaviors are available:
365
371
366
372
$services->set(Bar::class)
367
373
->decorate(Foo::class, null, 0, ContainerInterface::IGNORE_ON_INVALID_REFERENCE)
368
- ->args([ref(Bar::class. '.inner')])
374
+ ->args([ref('.inner')])
369
375
;
370
376
};
371
377
0 commit comments