You are here

function rules_variable::save_changes in Rules 6

Saves the variable to db, if necessary

File

rules/rules.variables.inc, line 351
Provides functions and classes for handling variables

Class

rules_variable
Handles loading and saving a variable

Code

function save_changes() {

  //if the variable is not saved automatically, save it
  if ($this->_changed && !$this->info['saved'] && $this->data
    ->is_savable()) {
    rules_log(t('Saved variable @name of type @type.', array(
      '@name' => $this->info['label'],
      '@type' => $this->info['type'],
    )));
    $return = $this->data
      ->save();
    $this->_changed = FALSE;
    if (!$return) {
      rules_log(t('Failed saving variable @name of type @type.', array(
        '@name' => $this->info['label'],
        '@type' => $this->info['type'],
      )), TRUE);
    }
  }
}