Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
faizanakram99 authored and nicolas-grekas committed Apr 29, 2024
1 parent eab49e6 commit fd58b3a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
1 change: 1 addition & 0 deletions UPGRADE-7.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ FrameworkBundle

* Mark classes `ConfigBuilderCacheWarmer`, `Router`, `SerializerCacheWarmer`, `TranslationsCacheWarmer`, `Translator` and `ValidatorCacheWarmer` as `final`
* Deprecate the `router.cache_dir` config option, the Router will always use the `kernel.build_dir` parameter
* Reset env vars when resetting the container

Intl
----
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CHANGELOG
* Attach the workflow's configuration to the `workflow` tag
* Add the `allowed_recipients` option for mailer to allow some users to receive
emails even if `recipients` is defined.
* Reset env vars on kernel.reset
* Reset env vars when resetting the container

7.0
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Bundle\FrameworkBundle\Secrets\DotenvVault;
use Symfony\Bundle\FrameworkBundle\Secrets\SodiumVault;
use Symfony\Component\DependencyInjection\StaticEnvVarLoader;

return static function (ContainerConfigurator $container) {
$container->services()
Expand All @@ -21,6 +22,9 @@
abstract_arg('Secret dir, set in FrameworkExtension'),
service('secrets.decryption_key')->ignoreOnInvalid(),
])

->set('secrets.env_var_loader', StaticEnvVarLoader::class)
->args([service('secrets.vault')])
->tag('container.env_var_loader')

->set('secrets.decryption_key')
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/DependencyInjection/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CHANGELOG
* Add argument `$prepend` to `FileLoader::construct()` to prepend loaded configuration instead of appending it
* [BC BREAK] When used in the `prependExtension()` method, the `ContainerConfigurator::import()` method now prepends the configuration instead of appending it
* Cast env vars to null or bool when referencing them using `#[Autowire(env: '...')]` depending on the signature of the corresponding parameter
* Add `StaticEnvVarLoader`

7.0
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\FrameworkBundle\Secrets;
namespace Symfony\Component\DependencyInjection;

use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
use Symfony\Component\DependencyInjection\Attribute\AutowireDecorated;
use Symfony\Component\DependencyInjection\EnvVarLoaderInterface;

/**
* @internal
*/
#[AsDecorator('secrets.vault')]
class StaticEnvVarLoader implements EnvVarLoaderInterface
{
private array $envCache = [];
private array $envVars;

public function __construct(
#[AutowireDecorated]
Expand All @@ -31,10 +26,6 @@ public function __construct(

public function loadEnvVars(): array
{
if ([] !== $this->envCache) {
return $this->envCache;
}

return $this->envCache = $this->envVarLoader->loadEnvVars();
return $this->envVars ??= $this->envVarLoader->loadEnvVars();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\FrameworkBundle\Tests\Secrets;
namespace Symfony\Component\DependencyInjection\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Secrets\StaticEnvVarLoader;
use Symfony\Component\DependencyInjection\EnvVarLoaderInterface;
use Symfony\Component\DependencyInjection\StaticEnvVarLoader;

class StaticEnvVarLoaderTest extends TestCase
{
Expand Down

0 comments on commit fd58b3a

Please sign in to comment.