public function testArray_merge_recursive_unique() { $array1 = array('element1', 'element2' => array('subkey1' => 'a', 'subkey2' => 'b'), 'element3' => 'a', array(1, 2, 3, 'key' => 'a')); $array2 = array('otherelement1', 'element2' => array('subkey1' => 'z', 'subkey3' => 'x'), 'element3' => 'b', array(4)); $expected = array('otherelement1', 'element2' => array('subkey1' => 'z', 'subkey2' => 'b', 'subkey3' => 'x'), 'element3' => 'b', array(4, 2, 3, 'key' => 'a')); $this->assertEqual(MArray::array_merge_recursive_unique($array1, $array2), $expected); }
protected function generateOptions() { $AuthOptions = PEAR::getStaticProperty('m_office', 'options'); $userOpt = $AuthOptions['auth']; $opt = array('all' => PEAR::getStaticProperty('Module', 'global')); $options = array('caching' => MODE == 'developpement' ? false : true, 'cacheDir' => $opt['all']['cacheDir'] . '/config/' . ($userOpt ? User::getInstance('office')->getId() . '/' : ''), 'lifeTime' => null, 'fileNameProtection' => false, 'automaticSerialization' => true); $optcache = new Cache_Lite($options); if (!($moduleopt = $optcache->get($this->_modulename))) { if (@(include_once $this->_path . $this->_modulename . '.conf.php')) { if (!is_array($config)) { $config = array(); } $moduleopt = MArray::array_merge_recursive_unique($opt, $config); } else { $moduleopt = $opt; } $useropt = Mreg::get('authHelper')->getPrivilegesForModule(User::getInstance('office'), $this->_modulename); $moduleopt = MArray::array_merge_recursive_unique($moduleopt, $useropt); $optcache->save($moduleopt); } return $moduleopt; }
/** * * description * * @return unknown_type */ protected function generateOptions($opt, $group = NULL) { $opt = array('all' => $opt); $options = array('caching' => MODE == 'developpement' ? false : true, 'cacheDir' => $opt['all']['cacheDir'] . '/config/', 'lifeTime' => 72000, 'fileNameProtection' => false, 'automaticSerialization' => true); Log::info('preparing options'); $optcache = new Cache_Lite($options); if (empty($group)) { $group = 'default'; } if (!($moduleopt = $optcache->get(get_class($this), $group))) { Log::info('no cache for options, live generating'); foreach ($this->_path as $path) { if (@(include $path . '/' . $this->_modulename . '.conf.php')) { Log::info('loading module config file'); if (!is_array($config)) { $config = array(); } $moduleopt = MArray::array_merge_recursive_unique($opt, $config); break; } else { $moduleopt = $opt; } Log::info('no cache for options, live generating'); } if (MODE != 'developpement') { $ret = $optcache->save($moduleopt); Log::info('group = ' . $group); if ($ret) { Log::info('options saved'); } } } Log::info('options prepared'); return $moduleopt; }