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

Appearance settings

Commit 48d02a1

Browse filesBrowse files
committed
minor #16779 [DependencyInjection] adjust Autowire attribute docs (kbond)
This PR was squashed before being merged into the 6.1 branch. Discussion ---------- [DependencyInjection] adjust `Autowire` attribute docs Follow up to #16629 per slack discussion. For services and expressions, explicitly use the named argument. Commits ------- fd05739 [DependencyInjection] adjust `Autowire` attribute docs
2 parents 742544c + fd05739 commit 48d02a1
Copy full SHA for 48d02a1

File tree

2 files changed

+8
-8
lines changed
Filter options

2 files changed

+8
-8
lines changed

‎controller.rst

Copy file name to clipboardExpand all lines: controller.rst
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ command:
225225
226226
.. tip::
227227

228-
If you need control over the *exact* value of an argument, you can use the
229-
``#[Autowire]`` attribute::
228+
If you need control over the *exact* value of an argument, or require a parameter,
229+
you can use the ``#[Autowire]`` attribute::
230230

231231
// ...
232232
use Psr\Log\LoggerInterface;
@@ -239,7 +239,7 @@ command:
239239
int $max,
240240

241241
// inject a specific logger service
242-
#[Autowire('@monolog.logger.request')]
242+
#[Autowire(service: 'monolog.logger.request')]
243243
LoggerInterface $logger,
244244

245245
// or inject parameter values

‎service_container/autowiring.rst

Copy file name to clipboardExpand all lines: service_container/autowiring.rst
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,8 @@ To fix this, you can :ref:`manually wire the problematic argument <services-manu
545545
in the service configuration. You wire up only the difficult arguments,
546546
Symfony takes care of the rest.
547547

548-
You can also use the ``#[Autowire]`` parameter attribute to configure the
549-
problematic arguments:
548+
You can also use the ``#[Autowire]`` parameter attribute to instruct the autowiring
549+
logic about those arguments:
550550

551551
// src/Service/MessageGenerator.php
552552
namespace App\Service;
@@ -557,7 +557,7 @@ problematic arguments:
557557
class MessageGenerator
558558
{
559559
public function __construct(
560-
#[Autowire('@monolog.logger.request')] LoggerInterface $logger
560+
#[Autowire(service: 'monolog.logger.request')] LoggerInterface $logger
561561
) {
562562
// ...
563563
}
@@ -586,8 +586,8 @@ and even :doc:`complex expressions </service_container/expression_language>`::
586586
#[Autowire('%kernel.debug%')]
587587
bool $debugMode,
588588

589-
// and @=... for expressions
590-
#[Autowire("@=service("App\\Mail\\MailerConfiguration").getMailerMethod()")]
589+
// and expressions
590+
#[Autowire(expression: "service("App\\Mail\\MailerConfiguration").getMailerMethod()")]
591591
string $mailerMethod
592592
) {
593593
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.