Skip to content

Commit e510f67

Browse files
committed
minor #7911 [DependencyInjection] Fix decorating service definition (michaelperrin)
This PR was merged into the 2.7 branch. Discussion ---------- [DependencyInjection] Fix decorating service definition There is an error, particularly on the YAML definition where the `decoration_inner_name` option is not defined on the correct service. It should be defined on the decorating service, and not on the decorated service. The XML definition was correct, but was lacking some properties to make things clearer. There PHP definition was not using the correct name of the decorated service. I have fixed the indentation as well on the YAML configuration. Commits ------- dabf122 Fix decorating service definition
2 parents 2ebd072 + dabf122 commit e510f67

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

service_container/service_decoration.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ a reference of the old one as ``app.decorating_mailer.inner``:
6161
# ...
6262
6363
app.decorating_mailer:
64-
class: AppBundle\DecoratingMailer
65-
decorates: app.mailer
66-
arguments: ['@app.decorating_mailer.inner']
67-
public: false
64+
class: AppBundle\DecoratingMailer
65+
decorates: app.mailer
66+
arguments: ['@app.decorating_mailer.inner']
67+
public: false
6868
6969
.. code-block:: xml
7070
@@ -128,7 +128,7 @@ convention, the old ``app.mailer`` service is renamed to
128128
.. code-block:: yaml
129129
130130
services:
131-
app.mailer:
131+
app.decorating_mailer:
132132
# ...
133133
decoration_inner_name: app.decorating_mailer.wooz
134134
arguments: ['@app.decorating_mailer.wooz']
@@ -144,7 +144,11 @@ convention, the old ``app.mailer`` service is renamed to
144144
<!-- ... -->
145145
146146
<service
147+
id="app.decorating_mailer"
148+
class="AppBundle\DecoratingMailer"
149+
decorates="app.mailer"
147150
decoration-inner-name="app.decorating_mailer.wooz"
151+
public="false"
148152
>
149153
<argument type="service" id="app.decorating_mailer.wooz" />
150154
</service>
@@ -158,7 +162,7 @@ convention, the old ``app.mailer`` service is renamed to
158162
use Symfony\Component\DependencyInjection\Reference;
159163
160164
$container->register('app.decorating_mailer', DecoratingMailer::class)
161-
->setDecoratedService('foo', 'app.decorating_mailer.wooz')
165+
->setDecoratedService('app.mailer', 'app.decorating_mailer.wooz')
162166
->addArgument(new Reference('app.decorating_mailer.wooz'))
163167
// ...
164168
;

0 commit comments

Comments
 (0)