From: Jason S. <jsw...@ya...> - 2003-05-22 16:27:59
|
Another tweak to Phrame I am considering implementing is to add an optional default value to the HashMap::Get method. The reason for this is because I use ActionForm::Get within my View objects in a similar fasion to the register() function I wrote some time ago ( http://www.zend.com/zend/art/art-sweat4.php#Heading12 ). This function allows for extraction of the posted parameters in a register_globals off environment, and optionally, you can specify a default value if the user did not get/post the desired value i.e. $foo = register('foo', 'bar'); would instead be: $foo = ActionForm->Get('foo', 'bar'); The current implementation would have to look like: $foo = ActionForm->Get('foo'); if (!$foo) $foo = 'bar'; My modification would be to add a constant and tweak the get method- define('PHRAME_HASHMAP_DEFAULT', '__PHRAME_HASHMAP_DEFAULT__'); /** * Returns the value to which the specified key is mapped in this identity * hash map, or null if the map contains no mapping for this key. * * @access public * @param mixed $key * @param mixed $default optional * @return mixed */ function get($key, $default=PHRAME_HASHMAP_DEFAULT) { if ($this->containsKey($key)) { return $this->_values[$key]; } else { if (PHRAME_HASHMAP_DEFAULT != $default) { return $default; } } } Should be backwards compatible. Thoughts? Regards, Jason __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com |