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

Commit0c6bcc6

Browse files
committed
minor#20901 [DependencyInjection] Add when argument to#[AsAlias] (Fan2Shrek)
This PR was merged into the 7.3 branch.Discussion----------[DependencyInjection] Add when argument to `#[AsAlias]`Fix#20884Commits-------316c8ac Add when argument to AsAlias
2 parentsa5cea71 +316c8ac commit0c6bcc6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎service_container/alias_private.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,27 @@ This means that when using the container directly, you can access the
181181
# ...
182182
app.mailer:'@App\Mail\PhpMailer'
183183
184+
The ``#[AsAlias]`` attribute also support per-environment configuration
185+
via the ``when`` argument::
186+
187+
// src/Mail/PhpMailer.php
188+
namespace App\Mail;
189+
190+
// ...
191+
use Symfony\Component\DependencyInjection\Attribute\AsAlias;
192+
193+
#[AsAlias(id: 'app.mailer', when: 'dev')]
194+
class PhpMailer
195+
{
196+
// ...
197+
}
198+
199+
You can pass either a string or an array of strings to the ``when`` argument.
200+
201+
..versionadded::7.3
202+
203+
The ``when`` argument on the ``#[AsAlias]`` attribute was introduced in Symfony 7.3.
204+
184205
..tip::
185206

186207
When using ``#[AsAlias]`` attribute, you may omit passing ``id`` argument

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp