You are here

function config_pages_import_form_submit in Config Pages 7

config_pages_import_form submit handler.

File

./config_pages.admin.inc, line 241
ConfigPages editing UI.

Code

function config_pages_import_form_submit(&$form, &$form_state) {

  // Load source config.
  $source_context = $form_state['values']['source'];
  $source_config = config_pages_load_entity($form['#config_pages']->type, $source_context);
  if (empty($source_config)) {
    drupal_set_message(t('Can not import config from context %context, as it is no longer available.', array(
      '%context' => config_pages_context_label($source_context),
    )), 'error');
    return;
  }
  $original_config = $form['#config_pages'];

  // Copy all data from source to dest.
  $exclude = array(
    'config_pages_id',
    'created',
    'changed',
    'language',
    'context',
  );
  foreach ($exclude as $key) {
    if (isset($source_config->{$key})) {
      unset($source_config->{$key});
    }
  }
  $config = config_pages_import_update('config_pages', $original_config->type, $source_config, $original_config);
  $config = config_pages_import_update_panelizer($original_config, $config);
  config_pages_save($config);
}