Skip to content

Commit

Permalink
minor #19794 Add ENV processor example (antoniovj1)
Browse files Browse the repository at this point in the history
This PR was merged into the 6.4 branch.

Discussion
----------

Add ENV processor example

Added example of autowiring with env processor

Commits
-------

face906 Add ENV processor example
  • Loading branch information
OskarStark committed Apr 17, 2024
2 parents e05c5b1 + face906 commit a53627b
Showing 1 changed file with 6 additions and 1 deletion.
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,
) {
}
// ...
Expand Down

0 comments on commit a53627b

Please sign in to comment.