You are here

function FrxReportGenerator::get_formatter in Forena Reports 6.2

Same name and namespace in other branches
  1. 7.2 FrxReportGenerator.inc \FrxReportGenerator::get_formatter()
  2. 7.3 FrxReportGenerator.inc \FrxReportGenerator::get_formatter()
  3. 7.4 FrxReportGenerator.inc \FrxReportGenerator::get_formatter()

Load the formatters for all initialized repositories.

1 call to FrxReportGenerator::get_formatter()
FrxReportGenerator::format_data in ./FrxReportGenerator.inc

File

./FrxReportGenerator.inc, line 330
Common functions used throughout the project but loaded in this file to keep the module file lean.

Class

FrxReportGenerator

Code

function get_formatter($fkey) {

  // Get all repositories
  $repos = $this
    ->repository();
  $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 = $this
    ->define_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;
}