Skip to content

Commit 430f932

Browse files
committed
[#6905] rewrite code example to cover the setter
1 parent 6aad11c commit 430f932

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

service_container/optional_dependencies.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ call if the service exists and remove the method call if it does not:
120120
));
121121
122122
In YAML, the special ``@?`` syntax tells the service container that the dependency
123-
is optional. Of course, the ``NewsletterManager`` must also be rewritten to
124-
allow for an optional dependency::
123+
is optional. Of course, the ``NewsletterManager`` must also be rewritten by
124+
adding a ``setMailer()`` method::
125125

126-
public function __construct(Mailer $mailer = null)
126+
public function setMailer(Mailer $mailer)
127127
{
128128
// ...
129129
}

0 commit comments

Comments
 (0)