|
4 | 4 |
|
5 | 5 | namespace AsyncAws\Symfony\Bundle\DependencyInjection; |
6 | 6 |
|
| 7 | +use AsyncAws\Symfony\Bundle\Secrets\CachedEnvVarLoader; |
7 | 8 | use AsyncAws\Symfony\Bundle\Secrets\SsmVault; |
8 | 9 | use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; |
9 | 10 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
10 | 11 | use Symfony\Component\DependencyInjection\ContainerInterface; |
11 | 12 | use Symfony\Component\DependencyInjection\Definition; |
12 | 13 | use Symfony\Component\DependencyInjection\Reference; |
13 | 14 | use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
| 15 | +use Symfony\Contracts\Cache\CacheInterface; |
14 | 16 |
|
15 | 17 | class AsyncAwsExtension extends Extension |
16 | 18 | { |
@@ -137,6 +139,20 @@ private function registerEnvLoader(ContainerBuilder $container, array $config): |
137 | 139 | $config['secrets']['path'], |
138 | 140 | $config['secrets']['recursive'], |
139 | 141 | ]); |
| 142 | + |
| 143 | + if ($config['secrets']['cache']['enabled']) { |
| 144 | + if (!\interface_exists(CacheInterface::class)) { |
| 145 | + throw new InvalidConfigurationException(sprintf('You have enabled "async_aws.secrets.cache" but the "symfony/cache" package is not installed. Try running "composer require symfony/cache"')); |
| 146 | + } |
| 147 | + |
| 148 | + $container->Register(CachedEnvVarLoader::class) |
| 149 | + ->setDecoratedService(SsmVault::class) |
| 150 | + ->setArguments([ |
| 151 | + new Reference(CachedEnvVarLoader::class . '.inner'), |
| 152 | + new Reference($config['secrets']['cache']['pool']), |
| 153 | + $config['secrets']['cache']['ttl'], |
| 154 | + ]); |
| 155 | + } |
140 | 156 | } |
141 | 157 |
|
142 | 158 | private function autowireServices(ContainerBuilder $container, array $usedServices): void |
|
0 commit comments