function _drush_cm_prepare_for_export

7.x _drush_cm_prepare_for_export(&$merge_info)
1 call to _drush_cm_prepare_for_export()


commands/core/, line 846
Provides Configuration Management commands.


function _drush_cm_prepare_for_export(&$merge_info) {
  $configuration_path = _drush_cm_get_configuration_path($merge_info);
  // The git transport only works if both sites have the same config path, so look up the
  // remote config path to see if this is the case, and error out if it is not.
  if ($merge_info['git-transport']) {
    $remote_configuration_path = _drush_cm_get_remote_configuration_path($merge_info);
    // n.b. $configuration_path is a relative path, whereas drupal-directory will give us
    // an absolute path.  We therefore compare only the ends of the strings.
    if ($configuration_path != substr(trim($remote_configuration_path), -strlen($configuration_path))) {
      return drush_set_error('CONFIG_MERGE_INCOMPATIBLE_PATHS', dt("The --git option only works when the configuration path is the same on the source and destination sites.  On your source site, the configuration path is !remote; on the target site, it was !local.  You must use the default transport mechanism (rsync).", array('!remote' => $configdir_values['output'], '!local' => $configuration_path)));

  // If the user did not supply a base commit, then we'll fill in
  // the current original hash as our base commit.
  if (!$merge_info['base']) {
    $merge_info['base'] = $merge_info['original_hash'];

  // Decide how we are going to transfer the exported configuration.
  $merge_info['export_options'] = array();

  // Check to see if the user wants to use git to transfer the configuration changes;
  // if so, set up the appropriate options to pass along to config-export.
  if ($merge_info['git-transport']) {
    $merge_info['export_options']['push'] = TRUE;
    $merge_info['export_options']['remote'] = $merge_info['remote'];
    $merge_info['export_options']['branch'] = $merge_info['live-config'];
  elseif ($merge_info['temp']) {
    if ($merge_info['temp'] === TRUE) {
      $merge_info['export_options']['destination'] = '%temp/config';
    else {
      $merge_info['export_options']['destination'] = $merge_info['temp'];

  // In rsync mode, this is where we will copy from.  (Skip this assignment if
  // someone already set up or looked up the remote path.)
  if (!isset($merge_info['remote_configuration_path'])) {
    $merge_info['remote_configuration_path'] = "%config-" . $merge_info['config-label'];
  $merge_info['rsync_options'] = array('delete' => TRUE);

  // Make a temporary copy of our configuration directory, so that we
  // can record what changed after calling config-export and merging.
  $merge_info['original_configuration_files'] = drush_tempdir() . '/original';
  drush_copy_dir($configuration_path, $merge_info['original_configuration_files'], FILE_EXISTS_OVERWRITE);