/** * Ensures that setDirectory() returns expected value * * @return void */ public function testSetDirectory() { $validator = new Zend_Validate_File_Exists('temp'); $validator->setDirectory('gif'); $this->assertEquals('gif', $validator->getDirectory()); $this->assertEquals(array('gif'), $validator->getDirectory(true)); $validator->setDirectory('jpg, temp'); $this->assertEquals('jpg,temp', $validator->getDirectory()); $this->assertEquals(array('jpg', 'temp'), $validator->getDirectory(true)); $validator->setDirectory(array('zip', 'ti')); $this->assertEquals('zip,ti', $validator->getDirectory()); $this->assertEquals(array('zip', 'ti'), $validator->getDirectory(true)); }
/** * Get the option variables from an xml file for the current dots * * Used recursively, first take default.xml values. This values are * overwritten by the xml of the current dots * * This method also stores the options in the cache, for faster access * * @param string $requestModule * @param string $requestController * @return Zend_Config */ public static function getOptionVariables($requestModule, $requestController) { $option = array(); // get the actual controller // fixes the any_inexistent_controller caching // eg: localhost/DotKernel/module/inexistent_controller/ $actualController = 'default'; if ($requestController == 'seo' || in_array($requestController, Dot_Route::getControllersForModule($requestModule))) { $actualController = $requestController; } $cacheKey = 'option_' . $requestModule . '_' . $actualController; $value = Dot_Cache::load($cacheKey); if ($value != false) { $option = $value; return $option; } else { if ('default' == $requestController) { $dirOption = CONFIGURATION_PATH . '/'; $fileOption = 'dots.xml'; } else { $dirOption = CONFIGURATION_PATH . '/dots/'; $fileOption = strtolower($requestController) . '.xml'; } $validFile = new Zend_Validate_File_Exists(); $validFile->setDirectory($dirOption); if ($validFile->isValid($fileOption)) { $xml = new Zend_Config_Xml($dirOption . $fileOption, 'dots'); $arrayOption = $xml->variable->toArray(); foreach ($arrayOption as $v) { if (in_array($v['option'], array('global', $requestModule))) { // first write global, then replace the values with the ones from $requestModule $option = array_replace_recursive($option, $v); } } } // overwritte the default options from dots.xml with the one of the current dots $option = new Zend_Config($option, true); if (Zend_Registry::isRegistered('option')) { $optionRegistered = Zend_Registry::get('option'); $optionRegistered->merge($option); $value = Dot_Cache::save($optionRegistered, $cacheKey); return $optionRegistered; } $value = Dot_Cache::save($option, $cacheKey); return $option; } }