Skip to content

Commit

Permalink
minor symfony#7911 [DependencyInjection] Fix decorating service defin…
Browse files Browse the repository at this point in the history
…ition (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
  • Loading branch information
xabbuh committed May 18, 2017
2 parents 2ebd072 + dabf122 commit e510f67
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions service_container/service_decoration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ a reference of the old one as ``app.decorating_mailer.inner``:
# ...
app.decorating_mailer:
class: AppBundle\DecoratingMailer
decorates: app.mailer
arguments: ['@app.decorating_mailer.inner']
public: false
class: AppBundle\DecoratingMailer
decorates: app.mailer
arguments: ['@app.decorating_mailer.inner']
public: false
.. code-block:: xml
Expand Down Expand Up @@ -128,7 +128,7 @@ convention, the old ``app.mailer`` service is renamed to
.. code-block:: yaml
services:
app.mailer:
app.decorating_mailer:
# ...
decoration_inner_name: app.decorating_mailer.wooz
arguments: ['@app.decorating_mailer.wooz']
Expand All @@ -144,7 +144,11 @@ convention, the old ``app.mailer`` service is renamed to
<!-- ... -->
<service
id="app.decorating_mailer"
class="AppBundle\DecoratingMailer"
decorates="app.mailer"
decoration-inner-name="app.decorating_mailer.wooz"
public="false"
>
<argument type="service" id="app.decorating_mailer.wooz" />
</service>
Expand All @@ -158,7 +162,7 @@ convention, the old ``app.mailer`` service is renamed to
use Symfony\Component\DependencyInjection\Reference;
$container->register('app.decorating_mailer', DecoratingMailer::class)
->setDecoratedService('foo', 'app.decorating_mailer.wooz')
->setDecoratedService('app.mailer', 'app.decorating_mailer.wooz')
->addArgument(new Reference('app.decorating_mailer.wooz'))
// ...
;
Expand Down

0 comments on commit e510f67

Please sign in to comment.