protected function loadFile($filePath) { $yml = array(); $dirname = dirname($filePath); $yaml = new \Symfony\Component\Yaml\Yaml(); $res = $yaml->parse($filePath); foreach ($res as $key => $value) { if ($key == 'include') { foreach ($value as $file) { $file = preg_replace_callback('`\\${env\\.([^}]+)}`i', function ($matches) { return getenv($matches[1]); }, $file); $subYml = $this->loadFile($dirname . '/' . $file); $yml = Arrays::mergeRecursiveUnique($yml, $subYml); } } else { $yml = Arrays::mergeRecursiveUnique($yml, array($key => $res[$key])); } } return $yml; }
/** * Set a parameter in the container on any key * @param [type] $key [description] * @param [type] $value [description] */ public function setParameter($key, $value) { $path = explode('.', $key); $this->validateParameter($key, $value); $root = array(); $r =& $root; foreach ($path as $subNode) { $r[$subNode] = array(); $r =& $r[$subNode]; } $r = $value; $r =& $root; if ($this->parameters) { $parameters = $this->parameters->extract(); } else { $parameters = array(); } $this->parameters = new ArrayResolver(Arrays::mergeRecursiveUnique($parameters, $r)); return $this; }