9e1edd4d3156885de631a460d12f512a5ba20635
[yaffs-website] / vendor / symfony / dependency-injection / Compiler / ResolveEnvPlaceholdersPass.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\DependencyInjection\Compiler;
13
14 use Symfony\Component\DependencyInjection\Definition;
15
16 /**
17  * Replaces env var placeholders by their current values.
18  */
19 class ResolveEnvPlaceholdersPass extends AbstractRecursivePass
20 {
21     protected function processValue($value, $isRoot = false)
22     {
23         if (\is_string($value)) {
24             return $this->container->resolveEnvPlaceholders($value, true);
25         }
26         if ($value instanceof Definition) {
27             $changes = $value->getChanges();
28             if (isset($changes['class'])) {
29                 $value->setClass($this->container->resolveEnvPlaceholders($value->getClass(), true));
30             }
31             if (isset($changes['file'])) {
32                 $value->setFile($this->container->resolveEnvPlaceholders($value->getFile(), true));
33             }
34         }
35
36         $value = parent::processValue($value, $isRoot);
37
38         if ($value && \is_array($value) && !$isRoot) {
39             $value = array_combine($this->container->resolveEnvPlaceholders(array_keys($value), true), $value);
40         }
41
42         return $value;
43     }
44 }