Skip to content

Commit fd05739

Browse files
kbondjaviereguiluz
authored andcommitted
[DependencyInjection] adjust Autowire attribute docs
1 parent e7acfd9 commit fd05739

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

controller.rst

Lines 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

Lines 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)