mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding Object::enum()
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4495 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
96abdcb619
commit
2c837ffac2
1 changed files with 16 additions and 0 deletions
|
@ -74,6 +74,22 @@ class Object{
|
|||
$class = get_class($this);
|
||||
return $class;
|
||||
}
|
||||
/**
|
||||
* Return a value from an array list.
|
||||
*
|
||||
* @param string $selected
|
||||
* @param array $list
|
||||
* @return string the value of the array key
|
||||
*/
|
||||
function enum($select, $list = array('no', 'yes')) {
|
||||
$return = null;
|
||||
if(is_array($list)){
|
||||
if (array_key_exists($select, $list)) {
|
||||
$return = $list[$select];
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
/**
|
||||
* Calls a controller's method from any location.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue