Skip to content

Navigation Menu

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 0c6bcc6

Browse filesBrowse 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 #20884 Commits ------- 316c8ac Add when argument to AsAlias
2 parents a5cea71 + 316c8ac commit 0c6bcc6
Copy full SHA for 0c6bcc6

File tree

1 file changed

+21
-0
lines changed
Filter options

1 file changed

+21
-0
lines changed

‎service_container/alias_private.rst

Copy file name to clipboardExpand all lines: service_container/alias_private.rst
+21Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.