Skip to content

Commit 2a58ea2

Browse files
committed
minor #13545 [DI] Updated the way inner services are referrer to in decoration (javiereguiluz)
This PR was merged into the master branch. Discussion ---------- [DI] Updated the way inner services are referrer to in decoration Fixes #13525. Commits ------- 0456253 [DI] Updated the way inner services are referrer to in decoration
2 parents ecf8815 + 0456253 commit 2a58ea2

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

reference/configuration/framework.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2866,7 +2866,7 @@ Name of the lock you want to create.
28662866
lock.invoice.retry_till_save.store:
28672867
class: Symfony\Component\Lock\Store\RetryTillSaveStore
28682868
decorates: lock.invoice.store
2869-
arguments: ['@lock.invoice.retry_till_save.store.inner', 100, 50]
2869+
arguments: ['@.inner', 100, 50]
28702870
28712871
workflows
28722872
~~~~~~~~~

service_container/service_decoration.rst

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Most of the time, that's exactly what you want to do. But sometimes,
5858
you might want to decorate the old one instead (i.e. apply the `Decorator pattern`_).
5959
In this case, the old service should be kept around to be able to reference
6060
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``:
6262

6363
.. configuration-block::
6464

@@ -70,7 +70,7 @@ but keeps a reference of the old one as ``App\DecoratingMailer.inner``:
7070
7171
App\DecoratingMailer:
7272
# 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"
7474
decorates: App\Mailer
7575
7676
.. code-block:: xml
@@ -84,6 +84,8 @@ but keeps a reference of the old one as ``App\DecoratingMailer.inner``:
8484
<services>
8585
<service id="App\Mailer"/>
8686
87+
<!-- overrides the App\Mailer service
88+
but that service is still available as ".inner" -->
8789
<service id="App\DecoratingMailer"
8890
decorates="App\Mailer"
8991
/>
@@ -106,7 +108,7 @@ but keeps a reference of the old one as ``App\DecoratingMailer.inner``:
106108
107109
$services->set(DecoratingMailer::class)
108110
// 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"
110112
->decorate(Mailer::class);
111113
};
112114
@@ -119,7 +121,7 @@ decorating service has one argument type-hinted with the decorated service class
119121
If you are not using autowiring or the decorating service has more than one
120122
constructor argument type-hinted with the decorated service class, you must
121123
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'``):
123125

124126
.. configuration-block::
125127

@@ -132,7 +134,7 @@ automatically changed to ``decorating_service_id + '.inner'``):
132134
App\DecoratingMailer:
133135
decorates: App\Mailer
134136
# pass the old service as an argument
135-
arguments: ['@App\DecoratingMailer.inner']
137+
arguments: ['@.inner']
136138
137139
.. code-block:: xml
138140
@@ -148,7 +150,7 @@ automatically changed to ``decorating_service_id + '.inner'``):
148150
<service id="App\DecoratingMailer"
149151
decorates="App\Mailer"
150152
>
151-
<argument type="service" id="App\DecoratingMailer.inner"/>
153+
<argument type="service" id=".inner"/>
152154
</service>
153155
154156
</services>
@@ -170,9 +172,13 @@ automatically changed to ``decorating_service_id + '.inner'``):
170172
$services->set(DecoratingMailer::class)
171173
->decorate(Mailer::class)
172174
// pass the old service as an argument
173-
->args([ref(DecoratingMailer::class.'.inner')]);
175+
->args([ref('.inner')]);
174176
};
175177
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'``.
176182

177183
.. tip::
178184

@@ -256,12 +262,12 @@ the ``decoration_priority`` option. Its value is an integer that defaults to
256262
Bar:
257263
decorates: Foo
258264
decoration_priority: 5
259-
arguments: ['@Bar.inner']
265+
arguments: ['@.inner']
260266
261267
Baz:
262268
decorates: Foo
263269
decoration_priority: 1
264-
arguments: ['@Baz.inner']
270+
arguments: ['@.inner']
265271
266272
.. code-block:: xml
267273
@@ -276,11 +282,11 @@ the ``decoration_priority`` option. Its value is an integer that defaults to
276282
<service id="Foo"/>
277283
278284
<service id="Bar" decorates="Foo" decoration-priority="5">
279-
<argument type="service" id="Bar.inner"/>
285+
<argument type="service" id=".inner"/>
280286
</service>
281287
282288
<service id="Baz" decorates="Foo" decoration-priority="1">
283-
<argument type="service" id="Baz.inner"/>
289+
<argument type="service" id=".inner"/>
284290
</service>
285291
</services>
286292
</container>
@@ -297,11 +303,11 @@ the ``decoration_priority`` option. Its value is an integer that defaults to
297303
298304
$services->set(Bar::class)
299305
->decorate(Foo::class, null, 5)
300-
->args([ref(Bar::class.'.inner')]);
306+
->args([ref('.inner')]);
301307
302308
$services->set(Baz::class)
303309
->decorate(Foo::class, null, 1)
304-
->args([ref(Baz::class.'.inner')]);
310+
->args([ref('.inner')]);
305311
};
306312
307313
@@ -331,7 +337,7 @@ Three different behaviors are available:
331337
Bar:
332338
decorates: Foo
333339
decoration_on_invalid: ignore
334-
arguments: ['@Bar.inner']
340+
arguments: ['@.inner']
335341
336342
.. code-block:: xml
337343
@@ -346,7 +352,7 @@ Three different behaviors are available:
346352
<service id="Foo"/>
347353
348354
<service id="Bar" decorates="Foo" decoration-on-invalid="ignore">
349-
<argument type="service" id="Bar.inner"/>
355+
<argument type="service" id=".inner"/>
350356
</service>
351357
</services>
352358
</container>
@@ -365,7 +371,7 @@ Three different behaviors are available:
365371
366372
$services->set(Bar::class)
367373
->decorate(Foo::class, null, 0, ContainerInterface::IGNORE_ON_INVALID_REFERENCE)
368-
->args([ref(Bar::class.'.inner')])
374+
->args([ref('.inner')])
369375
;
370376
};
371377

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy