You are here

function forena_define_controls in Forena Reports 7

Same name and namespace in other branches
  1. 6 forena.common.inc \forena_define_controls()

returns a list of instances of the control classes if there wasn't a class, returns an empty string.

6 calls to forena_define_controls()
forena_get_doctypes in ./forena.common.inc
Gets the correct format function to render the document and returns an object of that class.
forena_get_formatter in ./forena.common.inc
Load the formatters for all initialized repositories.
forena_get_templates in ./forena.common.inc
Returns an object of the template class that has a method named templates.
forena_supported_doctypes in ./forena.common.inc
forena_supported_formats in ./forena.common.inc

... See full list

File

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

Code

function forena_define_controls($class = '') {
  static $instances = '';
  if (!$instances) {
    $classes = forena_controls();
    foreach ($classes as $c) {
      if ($class == '' || $class == $c['class']) {
        if ($c['file'] && $c['module']) {
          include_once drupal_get_path('module', $c['module']) . '/' . trim($c['file'], '/');
          if (class_exists($c['class'])) {
            $instances[$c['class']] = new $c['class']();
          }
        }
      }
    }
  }
  if ($class && $instances[$class]) {
    return $instances[$class];
  }
  return $instances;
}