Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ENV processor example #19794

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all 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
7 changes: 6 additions & 1 deletion service_container/autowiring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,8 @@ logic about those arguments::

The ``#[Autowire]`` attribute can also be used for :ref:`parameters <service-parameters>`,
:doc:`complex expressions </service_container/expression_language>` and even
:ref:`environment variables <config-env-vars>`::
:ref:`environment variables <config-env-vars>` ,
:doc:`including env variable processors </configuration/env_var_processors>`::

// src/Service/MessageGenerator.php
namespace App\Service;
Expand All @@ -640,6 +641,10 @@ The ``#[Autowire]`` attribute can also be used for :ref:`parameters <service-par
// environment variables
#[Autowire(env: 'SOME_ENV_VAR')]
string $senderName,

// environment variables with processors
#[Autowire(env: 'bool:SOME_BOOL_ENV_VAR')]
string $allowAttachments,
antoniovj1 marked this conversation as resolved.
Show resolved Hide resolved
) {
}
// ...
Expand Down
Loading