You are here

function FrxReportGenerator::get_formatter in Forena Reports 7.4

Same name and namespace in other branches
  1. 6.2 FrxReportGenerator.inc \FrxReportGenerator::get_formatter()
  2. 7.2 FrxReportGenerator.inc \FrxReportGenerator::get_formatter()
  3. 7.3 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 58
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 = Frx::RepoMan()->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;
}