You are here

function delta_injection::presave in Delta 7.3

@todo

File

plugins/delta/delta_injection.inc, line 83

Class

delta_injection

Code

function presave($form, &$form_state) {
  if ($this->delta->mode == DELTA_PRESERVE) {
    $base = array();
    if (!empty($this->delta->parent)) {
      if ($plugin = delta_get_plugin($this->delta->parent, $this->plugin['name'])) {
        foreach ($this
          ->variables() as $variable) {
          $base[$variable] = $plugin
            ->config($variable);
        }
      }
    }
    foreach ($this
      ->variables() as $variable) {
      if (isset($base[$variable])) {
        $this->delta->settings[$variable] = delta_reduce($this->delta->settings[$variable], $base[$variable]);
      }
      else {
        $this->delta->settings[$variable] = delta_reduce(is_array($this->delta->settings[$variable]) ? $this->delta->settings[$variable] : array(), is_array(variable_get($variable)) ? variable_get($variable) : array());
      }
    }
  }
}