replaced ucfirst by underscoreToCamelcase for calculating method name

This commit is contained in:
Franck Allimant
2014-06-05 18:49:40 +02:00
parent 5873b29fc1
commit 0bb24298aa

View File

@@ -402,7 +402,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
return $noGetterData[$keyAttribute];
}
$getter = sprintf("get%s", ucfirst($attribute));
$getter = sprintf("get%s", underscoreToCamelcase($attribute));
if (method_exists($data, $getter)) {
$return = $data->$getter();
@@ -427,6 +427,26 @@ class DataAccessFunctions extends AbstractSmartyPlugin
return '';
}
/**
* Transcode an underscored string into a camel-cased string, eg. default_folder into DefaultFolder
*
* @param string $str the string to convert from underscore to camel-case
*
* @return string the camel cased string.
*/
private function underscoreToCamelcase($str) {
// Split string in words.
$words = explode('_', strtolower($str));
$return = '';
foreach ($words as $word) {
$return .= ucfirst(trim($word));
}
return $return;
}
/**
* Define the various smarty plugins hendled by this class
*