From 3ff812d799a3abdfc64f72956fe0fa0bd2c955fd Mon Sep 17 00:00:00 2001 From: Beno!t POLASZEK Date: Sun, 14 Feb 2021 10:42:34 +0100 Subject: [PATCH] [DependencyInjection] Negated (not:) env var processor --- configuration/env_var_processors.rst | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/configuration/env_var_processors.rst b/configuration/env_var_processors.rst index 407b5137fbc..2b42559911f 100644 --- a/configuration/env_var_processors.rst +++ b/configuration/env_var_processors.rst @@ -136,6 +136,46 @@ Symfony provides the following env var processors: 'http_method_override' => '%env(bool:HTTP_METHOD_OVERRIDE)%', ]); +``env(not:FOO)`` + + .. versionadded:: 5.3 + + The ``not:`` env var processor was introduced in Symfony 5.3. + + Casts ``FOO`` to a bool (just as ``env(bool:...)`` does) except it returns the inverted value + (falsy values are returned as ``true``, truthy values are returned as ``false``): + + .. configuration-block:: + + .. code-block:: yaml + + # config/services.yaml + parameters: + safe_for_production: '%env(not:APP_DEBUG)%' + + .. code-block:: xml + + + + + + + %env(not:APP_DEBUG)% + + + + + .. code-block:: php + + // config/services.php + $container->setParameter('safe_for_production', '%env(not:APP_DEBUG)%'); + ``env(int:FOO)`` Casts ``FOO`` to an int.