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

[DependencyInjection] adjustAutowire attribute docs#16779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
javiereguiluz merged 1 commit intosymfony:6.1fromkbond:autowire-attr-adjust
May 4, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletionscontroller.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -225,8 +225,8 @@ command:

.. tip::

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

// ...
use Psr\Log\LoggerInterface;
Expand All@@ -239,7 +239,7 @@ command:
int $max,

// inject a specific logger service
#[Autowire('@monolog.logger.request')]
#[Autowire(service: 'monolog.logger.request')]
LoggerInterface $logger,

// or inject parameter values
Expand Down
10 changes: 5 additions & 5 deletionsservice_container/autowiring.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -545,8 +545,8 @@ To fix this, you can :ref:`manually wire the problematic argument <services-manu
in the service configuration. You wire up only the difficult arguments,
Symfony takes care of the rest.

You can also use the ``#[Autowire]`` parameter attribute toconfigure the
problematic arguments:
You can also use the ``#[Autowire]`` parameter attribute toinstruct the autowiring
logic about those arguments:

// src/Service/MessageGenerator.php
namespace App\Service;
Expand All@@ -557,7 +557,7 @@ problematic arguments:
class MessageGenerator
{
public function __construct(
#[Autowire('@monolog.logger.request')] LoggerInterface $logger
#[Autowire(service: 'monolog.logger.request')] LoggerInterface $logger
) {
// ...
}
Expand DownExpand Up@@ -586,8 +586,8 @@ and even :doc:`complex expressions </service_container/expression_language>`::
#[Autowire('%kernel.debug%')]
bool $debugMode,

// and@=... forexpressions
#[Autowire("@=service("App\\Mail\\MailerConfiguration").getMailerMethod()")]
// and expressions
#[Autowire(expression: "service("App\\Mail\\MailerConfiguration").getMailerMethod()")]
string $mailerMethod
) {
}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp