コード例 #1
0
 /**
  *
  * @see Ai1ec_Write_Data_To_Cache::write_data()
  *
  */
 public function write_data($key, $value)
 {
     $result = $this->db_adapter->write_data_to_config($key, $value);
     if (false === $result) {
         throw new Ai1ec_Cache_Write_Exception("An error occured while saving data to {$key}");
     }
 }
 /**
  * After updating core themes, we also need to update the LESS variables with
  * the new ones as they may have changed. This function assumes that the
  * user_variables.php file in the active theme and/or parent theme has just
  * been updated.
  */
 public function update_less_variables_on_theme_update()
 {
     // Get old variables from the DB.
     $saved_variables = self::get_saved_variables($this->db_adapter);
     // Get the new variables from file.
     $new_variables = $this->get_less_variable_data_from_config_file(Ai1ec_Less_Factory::create_less_file_instance(Ai1ec_Less_File::USER_VARIABLES_FILE));
     foreach ($new_variables as $variable_name => $variable_data) {
         unset($variable_data['description']);
         // If the variable already exists, keep the old value.
         if (isset($saved_variables[$variable_name])) {
             $variable_data['value'] = $saved_variables[$variable_name]['value'];
         }
         $new_variables[$variable_name] = $variable_data;
     }
     // Wave the new variables to the DB.
     $this->db_adapter->write_data_to_config(self::DB_KEY_FOR_LESS_VARIABLES, $new_variables);
 }