From 1b6fcda552a6ded8528e75befd350b19a8647645 Mon Sep 17 00:00:00 2001 From: Nicolas Clavaud Date: Fri, 9 Nov 2018 20:37:35 +0100 Subject: [PATCH 1/2] Update service_decoration.rst Make it clear that the first paragraph is *not* about decorating a service, but completely overriding it. Decorating is explained in the next paragraph, so the reference to the decorator pattern has been moved there. Otherwise it's easy to get confused when reading the doc. The original text was clear, but the meaning changed when the file was moved, in commit https://github.com/symfony/symfony-docs/commit/141e922e0c1a1bf3d0b62cc8bf343ccb848f71a9#diff-ebbbc2e2adacde7254ce22cf2a32198c --- service_container/service_decoration.rst | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/service_container/service_decoration.rst b/service_container/service_decoration.rst index 17795dab58e..fc9b664c92a 100644 --- a/service_container/service_decoration.rst +++ b/service_container/service_decoration.rst @@ -4,8 +4,7 @@ How to Decorate Services ======================== -When overriding an existing definition (e.g. when applying the `Decorator pattern`_), -the original service is lost: +When overriding an existing definition, the original service is lost: .. configuration-block:: @@ -18,7 +17,7 @@ the original service is lost: # this replaces the old app.mailer definition with the new one, the # old definition is lost app.mailer: - class: AppBundle\DecoratingMailer + class: AppBundle\NewMailer .. code-block:: xml @@ -32,26 +31,26 @@ the original service is lost: - + .. code-block:: php use AppBundle\Mailer; - use AppBundle\DecoratingMailer; + use AppBundle\NewMailer; $container->register('app.mailer', Mailer::class); // this replaces the old app.mailer definition with the new one, the // old definition is lost - $container->register('app.mailer', DecoratingMailer::class); + $container->register('app.mailer', NewMailer::class); Most of the time, that's exactly what you want to do. But sometimes, -you might want to decorate the old one instead. In this case, the -old service should be kept around to be able to reference it in the -new one. This configuration replaces ``app.mailer`` with a new one, but keeps -a reference of the old one as ``app.decorating_mailer.inner``: +you might want to decorate the old one instead (i.e. apply the `Decorator pattern`_). +In this case, the old service should be kept around to be able to reference +it in the new one. This configuration replaces ``app.mailer`` with a new one, +but keeps a reference of the old one as ``app.decorating_mailer.inner``: .. configuration-block:: From 0e33dce3b00b92c1266221cf95d8c0cd72fe43c6 Mon Sep 17 00:00:00 2001 From: Nicolas Clavaud Date: Sat, 10 Nov 2018 21:00:36 +0100 Subject: [PATCH 2/2] Remove double space --- service_container/service_decoration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service_container/service_decoration.rst b/service_container/service_decoration.rst index fc9b664c92a..4021535d48a 100644 --- a/service_container/service_decoration.rst +++ b/service_container/service_decoration.rst @@ -50,7 +50,7 @@ Most of the time, that's exactly what you want to do. But sometimes, you might want to decorate the old one instead (i.e. apply the `Decorator pattern`_). In this case, the old service should be kept around to be able to reference it in the new one. This configuration replaces ``app.mailer`` with a new one, -but keeps a reference of the old one as ``app.decorating_mailer.inner``: +but keeps a reference of the old one as ``app.decorating_mailer.inner``: .. configuration-block::