Skip to content

Commit 0386306

Browse files
nclavaudxabbuh
authored andcommitted
Update service_decoration.rst
1 parent 06b1ee6 commit 0386306

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

service_container/service_decoration.rst

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
How to Decorate Services
55
========================
66

7-
When overriding an existing definition (e.g. when applying the `Decorator pattern`_),
8-
the original service is lost:
7+
When overriding an existing definition, the original service is lost:
98

109
.. configuration-block::
1110

@@ -18,7 +17,7 @@ the original service is lost:
1817
# this replaces the old app.mailer definition with the new one, the
1918
# old definition is lost
2019
app.mailer:
21-
class: AppBundle\DecoratingMailer
20+
class: AppBundle\NewMailer
2221
2322
.. code-block:: xml
2423
@@ -32,26 +31,26 @@ the original service is lost:
3231
3332
<!-- this replaces the old app.mailer definition with the new
3433
one, the old definition is lost -->
35-
<service id="app.mailer" class="AppBundle\DecoratingMailer" />
34+
<service id="app.mailer" class="AppBundle\NewMailer" />
3635
</services>
3736
</container>
3837
3938
.. code-block:: php
4039
4140
use AppBundle\Mailer;
42-
use AppBundle\DecoratingMailer;
41+
use AppBundle\NewMailer;
4342
4443
$container->register('app.mailer', Mailer::class);
4544
4645
// this replaces the old app.mailer definition with the new one, the
4746
// old definition is lost
48-
$container->register('app.mailer', DecoratingMailer::class);
47+
$container->register('app.mailer', NewMailer::class);
4948
5049
Most of the time, that's exactly what you want to do. But sometimes,
51-
you might want to decorate the old one instead. In this case, the
52-
old service should be kept around to be able to reference it in the
53-
new one. This configuration replaces ``app.mailer`` with a new one, but keeps
54-
a reference of the old one as ``app.decorating_mailer.inner``:
50+
you might want to decorate the old one instead (i.e. apply the `Decorator pattern`_).
51+
In this case, the old service should be kept around to be able to reference
52+
it in the new one. This configuration replaces ``app.mailer`` with a new one,
53+
but keeps a reference of the old one as ``app.decorating_mailer.inner``:
5554

5655
.. configuration-block::
5756

0 commit comments

Comments
 (0)