You are here

public function Loader::fromCache in Form Builder 7.2

Load a form from the form_builder_cache.

File

src/Loader.php, line 152

Class

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

Namespace

Drupal\form_builder

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;
}