You are here

function _configuration_export_to_datastore in Configuration Management 7.2

1 string reference to '_configuration_export_to_datastore'
configuration_drush_command in ./configuration.drush.inc
Implements of hook_drush_command().

File

./configuration.drush.inc, line 300
configuration.drush.inc Let you perform configuration actions from the console.

Code

function _configuration_export_to_datastore() {
  $export_all = drush_get_option('all');
  if (!empty($export_all)) {
    $args = _components_indentifier_formater();
  }
  else {
    $args = func_get_args();
  }
  if (empty($args)) {
    return drush_set_error('', dt('No configurations were selected to export'));
  }
  $handlers = ConfigurationManagement::getConfigurationHandler();
  foreach ($args as $arg) {
    list($component, $identifier) = explode('.', $arg, 2);
    if (empty($handlers[$component])) {
      return drush_set_error('', dt('The component @component is not valid or the module to export the configuration is not installed.', array(
        '@component' => $component,
      )));
    }
    if (empty($identifier)) {
      return drush_set_error('', dt('No identifier supplied for @arg.', array(
        '@arg' => $arg,
      )));
    }
  }
  $rows = array();
  $export_dependencies = !drush_get_option('exclude-dependencies');
  $export_optionals = !drush_get_option('exclude-optionals');
  $start_tracking = drush_get_option('start-tracking');
  $result = ConfigurationManagement::exportToDataStore($args, $export_dependencies, $export_optionals, $start_tracking);
  $hashes = $result
    ->getInfo('hash');
  foreach ($result
    ->getInfo('exported') as $id => $exported) {
    $rows[] = array(
      'exported' => $exported,
      'hash' => $hashes[$id],
    );
  }
  drush_log(dt('The configurations for the following items have been created/updated.'), 'ok');
  drush_print_table($rows);
}