I am writing custom code to programmatically customize an exported configuration, and then programmatically import this customized configuration as a new configuration.

I have two questions about importing the new configuration

Question #1: How to handle the cid

The exported configuration contains code that sets the cid in a bunch of places, eg:

$configuration->cid = '4';
$configuration->process->cid =  '4';
$configuration->complete->configuration['cid'] =  '4';

I don't want to update the exported configuration, I want to create a new configuration. So I need a new cid. Here is how I am currently getting the next available cid:
$sql = "SELECT auto_increment FROM information_schema.tables WHERE table_name='media_mover_config_list' AND table_schema = DATABASE()";

Is it possible to import my customized configuration without my having to supply a cid?

Question #2: How to do the import

I found this code in mediamover_api_io.inc:

function media_mover_api_import_config_form_submit($form, &$form_state) {
  // evaluate imported code
  ob_start();
  eval($form_state['values']['config']);
  ob_end_clean();

  // create a cache id
  $id = time();

  // Store the configuration
  // this is kind of a hack, but it works well enough
  cache_set("media_mover_config_$id", $configuration, 'cache');
  drupal_set_message(t('Successfully imported Media Mover configuration: !name.', array('!name' => $configuration->name)));
  $form_state['redirect'] = 'admin/build/media_mover/add/'. $id;
}

I don't really understand how this code is supposed to work. Here is my failed attempt at modifying the code to it imports a configuration object rather than a form:

  $id = time();
  cache_set("media_mover_config_$id", $configuration, 'cache');
  drupal_set_message(t('Successfully imported Media Mover configuration: !name.', array('!name' => $configuration->name)));

This doesn't work.
How do you recommend I import a configuration object in 6.x-1.x?

Thanks very much,
Mindy

Comments

kobnim’s picture

I'm sorry, I now see this is an approximate duplicate of http://drupal.org/node/806820.

arthurf’s picture

Status: Active » Closed (duplicate)

Closing in favor of #806820

arthurf’s picture

Issue summary: View changes

updated the information with latest results