You are here

public static function Frx::formatter in Forena Reports 7.5

Load the formatters for all initialized repositories.

1 call to Frx::formatter()
Frx::format in ./Frx.inc

File

./Frx.inc, line 410
Frx.incL General Forena Reporting Class

Class

Frx

Code

public static function formatter($fkey) {

  // Get all repositories
  $repos = Frx::DataManager()->repositories;
  $formats = array();
  foreach ($repos as $k => $r) {
    $provider = isset($r['data']) ? $r['data'] : NULL;
    if ($provider && method_exists($provider, 'formats')) {
      $f = $provider
        ->formats();
      if (isset($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 = Frx::Controls();
  foreach ($controls as $k => $r) {
    $provider = $r;
    if ($provider && method_exists($provider, 'formats')) {
      $f = $provider
        ->formats();
      if (isset($f[$fkey]) && method_exists($provider, $fkey)) {

        // We found an object with the advertised method return it
        return $provider;
      }
    }
  }
  return $formats;
}