function drush_content_export_yaml_cim_term in Content Export YAML 8
File
- drush/
content_export_yaml.drush.inc, line 284
Code
function drush_content_export_yaml_cim_term($bundle = NULL, $id = NULL) {
$bundle_list = \Drupal\taxonomy\Entity\Vocabulary::loadMultiple();
$bundle_list_name = array_keys($bundle_list);
if ($bundle == NULL) {
drush_print('Vocabulary is required ,it should be one of : ' . implode(" - ", $bundle_list_name));
}
else {
$export = new ContentExport();
if (!in_array($bundle, $bundle_list_name)) {
drush_print('That Vocabulary not exist , it should be one of : ' . implode(" - ", $bundle_list_name));
return NULL;
}
if ($id) {
$start = $id;
$end = $id;
}
else {
drush_print('Please enter Range ID you want to export : ');
$start = drush_prompt(dt('Start To'));
$end = drush_prompt(dt('End'));
}
if ($id == 'all') {
$result = $export
->load_entity_config_list('taxonomy_term', $bundle);
}
else {
$result = $export
->load_entity_config_list('taxonomy_term', $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 + 1,
'total' => $total,
'entity' => 'taxonomy_term',
'id_label' => 'tid',
'bundle_label' => 'vid',
'type' => $bundle,
];
$operations[] = [
'content_export_yaml_cim_index_batch_process',
[
$info,
],
];
}
$batch = [
'operations' => $operations,
'title' => t('Import block 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 Import Canceled');
}
}
else {
drush_print('No items are found');
}
}
}