I've done a helper method that some of you might find usefull, too. It's in
global scope (non class method):
// method extract_params {{{
/**
* Non class method extract_params extracts the params passed to
* a module to class vars.
* Called within the constructor method of you module like:
*
* extract_params($this, $_params)
*
* It actually does the following:
*
* - copies $_params to $this->params
* - references each key of $this->params to $this->key
*
* @param object The object instance this functions should applied to
* @param array The parameter array passed to the constructor
* @return bool True/false
* @author Andreas Aderhold, an...@bi...
* @access public
*/
function extract_params(&$_cls, $_params) {
if (!is_array($_params)) {
return;
}
$_cls->params = $_params;
foreach (array_keys($_cls->params) as $name) {
$_cls->$name =& $_cls->params[$name];
}
}
// }}}
Andi
|