8000 refactor(core): refactoring on multiples suggestions · symfony/symfony-docs@577760f · GitHub
[go: up one dir, main page]

Skip to content

Commit 577760f

Browse files
committed
refactor(core): refactoring on multiples suggestions
Fix on ticks Fix on method usage MailerInterface namespace added
1 parent 050caf3 commit 577760f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

service_container/calls.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ To configure the container to call the ``setLogger`` method, use the ``calls`` k
7575
When it comes to optional dependencies, the setter approach can be useful but
7676
what if you need to change the injected dependency without mutating the initial service?
7777

78-
To do so, you probably could use `immutable-setter` injection::
78+
To do so, you probably could use ``immutable-setter`` injection::
7979

8080
namespace App\Service;
8181

@@ -99,7 +99,9 @@ To do so, you probably could use `immutable-setter` injection::
9999
// ...
100100
}
101101

102-
In order to use this approach fully, just adapt the container configuration:
102+
Because the method returns a separate cloned instance, configuring such a service means using
103+
the return value of the wither method (``$service = $service->withLogger($logger);``).
104+
The configuration to tell the container it should do so would be like:
103105

104106
.. configuration-block::
105107

@@ -113,7 +115,7 @@ In order to use this approach fully, just adapt the container configuration:
113115
- method: withLogger
114116
arguments:
115117
- '@logger'
116-
use_result: true
118+
use_result: true
117119
118120
.. code-block:: xml
119121

service_container/injection_types.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Another possible injection is to use a method which returns a separate instance
107107
by cloning the original service, this approach allows you to make a service immutable::
108108

109109
// ...
110+
use Symfony\Component\Mailer\MailerInterface;
110111

111112
class NewsletterManager
112113
{

0 commit comments

Comments
 (0)
0