You are here

public function FormBuilderLoader::fromCache in Form Builder 7

Load a form from the form_builder_cache.

File

./form_builder.classes.inc, line 150

Class

FormBuilderLoader
This class is a wrapper around all the hooks used for getting pluigns.

Code

public function fromCache($form_type, $form_id, $sid = NULL, $reset = FALSE) {
  if ($reset) {
    $this->formCache = array();
  }
  if ($form_type && $form_id) {
    if (empty($this->formCache[$form_type][$form_id])) {
      $this->formCache[$form_type][$form_id] = FALSE;
      if (isset($this->formTypeInfo[$form_type])) {
        $info = $this->formTypeInfo[$form_type];
        $class = $info['class'];
        $sid = $sid ? $sid : session_id();
        if ($form = $class::load($form_type, $form_id, $sid, $info)) {
          $this->formCache[$form_type][$form_id] = $form;
        }
      }
    }
    return $this->formCache[$form_type][$form_id];
  }
  return NULL;
}