Skip to content

Commit e6e5e39

Browse files
authored
Add ENV processor example
1 parent a5cbeaf commit e6e5e39

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

service_container/autowiring.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ logic about those arguments::
614614

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

619619
// src/Service/MessageGenerator.php
620620
namespace App\Service;
@@ -635,11 +635,15 @@ The ``#[Autowire]`` attribute can also be used for :ref:`parameters <service-par
635635

636636
// expressions
637637
#[Autowire(expression: 'service("App\\\Mail\\\MailerConfiguration").getMailerMethod()')]
638-
string $mailerMethod
638+
string $mailerMethod,
639639

640640
// environment variables
641641
#[Autowire(env: 'SOME_ENV_VAR')]
642-
string $senderName
642+
string $senderName,
643+
644+
// environment variables with processors
645+
#[Autowire(env: 'bool:SOME_BOOL_ENV_VAR')]
646+
string $allowAttachments,
643647
) {
644648
}
645649
// ...

0 commit comments

Comments
 (0)