/** * Imports other configuration files and resolves references. * * @param array $data The data. * @param string $file The file source. * * @return array The processed data. * * @throws ImportException If "imports" is invalid. * @throws InvalidReferenceException If an invalid reference is used. */ public function process($data, $file) { if (empty($data)) { return array(); } if (isset($data['imports'])) { if (false === is_array($data['imports'])) { throw ImportException::format('The "imports" value is not valid in "%s".', $file); } $dir = dirname($file); foreach ($data['imports'] as $i => $import) { if (false === is_array($import)) { throw ImportException::format('One of the "imports" values (#%d) is not valid in "%s".', $i, $file); } if (false === isset($import['resource'])) { throw ImportException::format('A resource was not defined for an import in "%s".', $file); } $this->setCurrentDir($dir); $data = array_replace_recursive($this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false), $data); } } $global = $this->wise ? $this->wise->getGlobalParameters() : array(); $_this = $this; ArrayUtil::walkRecursive($data, function (&$value, $key, &$array) use(&$data, $global, $_this) { $value = $_this->doReplace($value, $data, $global); if (false !== strpos($key, '%')) { unset($array[$key]); $key = $_this->doReplace($key, $data, $global); $array[$key] = $value; } }); return $data; }
/** * @depends testGetGlobalParameters */ public function testSetGlobalParameters() { $this->wise->setGlobalParameters(array('value' => 123)); $this->assertEquals(array('value' => 123), $this->wise->getGlobalParameters()); }