function forena_get_formatter in Forena Reports 6
Same name and namespace in other branches
- 7 forena.common.inc \forena_get_formatter()
Load the formatters for all initialized repositories.
1 call to forena_get_formatter()
File
- ./
forena.common.inc, line 322 - Common functions used throughout the project but loaded in this file to keep the module file lean.
Code
function forena_get_formatter($fkey) {
// Get all repositories
$repos = forena_repository();
foreach ($repos as $k => $r) {
$provider = $r['data'];
if ($provider && method_exists($provider, 'formats')) {
$f = $provider
->formats();
if ($f[$fkey] && method_exists($provider, $fkey)) {
// We found an object with the advertised method return it
return $provider;
}
}
}
//Did not find the formater in the data provider
//Look to see if it's in a control class
$controls = forena_define_controls();
foreach ($controls as $k => $r) {
$provider = $r;
if ($provider && method_exists($provider, 'formats')) {
$f = $provider
->formats();
if ($f[$fkey] && method_exists($provider, $fkey)) {
// We found an object with the advertised method return it
return $provider;
}
}
}
return $formats;
}