Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2777dee

Browse files
committed
Fixed method chaining indentation
1 parentc0afd63 commit2777dee

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

‎components/dependency_injection/introduction.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Then you can set the choice of transport in the container::
6767
$container = new ContainerBuilder();
6868
$container
6969
->register('mailer', 'Mailer')
70-
->addArgument('sendmail');
70+
->addArgument('sendmail');
7171

7272
This class is now much more flexible as you have separated the choice of
7373
transport out of the implementation and into the container.
@@ -83,7 +83,7 @@ it a parameter in the container and then referring to this parameter for the
8383
$container->setParameter('mailer.transport', 'sendmail');
8484
$container
8585
->register('mailer', 'Mailer')
86-
->addArgument('%mailer.transport%');
86+
->addArgument('%mailer.transport%');
8787

8888
Now that the ``mailer`` service is in the container you can inject it as
8989
a dependency of other classes. If you have a ``NewsletterManager`` class
@@ -111,11 +111,11 @@ Then you can register this as a service as well and pass the ``mailer`` service
111111
$container->setParameter('mailer.transport', 'sendmail');
112112
$container
113113
->register('mailer', 'Mailer')
114-
->addArgument('%mailer.transport%');
114+
->addArgument('%mailer.transport%');
115115

116116
$container
117117
->register('newsletter_manager', 'NewsletterManager')
118-
->addArgument(new Reference('mailer'));
118+
->addArgument(new Reference('mailer'));
119119

120120
If the ``NewsletterManager`` did not require the ``Mailer`` and injecting
121121
it was only optional then you could use setter injection instead::
@@ -143,11 +143,11 @@ If you do want to though then the container can call the setter method::
143143
$container->setParameter('mailer.transport', 'sendmail');
144144
$container
145145
->register('mailer', 'Mailer')
146-
->addArgument('%mailer.transport%');
146+
->addArgument('%mailer.transport%');
147147

148148
$container
149149
->register('newsletter_manager', 'NewsletterManager')
150-
->addMethodCall('setMailer', new Reference('mailer'));
150+
->addMethodCall('setMailer', new Reference('mailer'));
151151

152152
You could then get your ``newsletter_manager`` service from the container
153153
like this::
@@ -261,4 +261,4 @@ The ``newsletter_manager`` and ``mailer`` services can be set up using config fi
261261
->register('newsletter_manager', 'NewsletterManager')
262262
->addMethodCall('setMailer', new Reference('mailer'));
263263
264-
.. _Packagist:https://packagist.org/packages/symfony/dependency-injection
264+
.. _Packagist:https://packagist.org/packages/symfony/dependency-injection

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp