function drush_content_export_yaml_cim_node in Content Export YAML 8
File
- drush/
content_export_yaml.drush.inc, line 546
Code
function drush_content_export_yaml_cim_node($bundle = NULL, $id = NULL) {
if ($bundle == NULL) {
drush_print('Parameter is required for example drush cim-node all ');
}
else {
$export = new ContentExport();
$bundle_array = $export
->content_type_list();
if (!in_array($bundle, array_keys($bundle_array))) {
drush_print('That node type not exist , it should be one of : ' . implode(" - ", array_keys($bundle_array)));
return NULL;
}
if ($id) {
$start = $id;
$end = $id;
}
else {
drush_print('Please enter Range file ID you want to insert : ');
$start = drush_prompt(dt('Start To'));
$end = drush_prompt(dt('End'));
}
if ($id == 'all') {
$result = $export
->load_entity_config_list('node', $bundle);
}
else {
$result = $export
->load_entity_config_list('node', $bundle, [
$start,
$end,
]);
}
if (!empty($result)) {
if (drush_confirm(dt('Find items ' . sizeof($result) . ' , Are you sure to continue the process ?'))) {
$total = sizeof($result);
foreach ($result as $key => $item) {
$info = [
'id' => $item,
'index' => $key,
'total' => $total,
];
$operations[] = [
'content_export_yaml_import_index_batch_process',
[
$info,
],
];
}
$batch = [
'operations' => $operations,
'title' => t('Import node content process'),
'init_message' => t('Starting...'),
'progress_message' => t('Completed @current of @total.'),
'error_message' => t('An error occurred'),
'finished' => 'content_export_batch_finish',
'file' => drupal_get_path('module', 'content_export_yaml') . '/drush/content_export_yaml.batch.inc',
];
// Start the batch job.
batch_set($batch);
drush_backend_batch_process();
}
else {
drush_print('Content Export Canceled');
}
}
else {
drush_print('No items are found');
}
}
}