content_export_yaml.batch.inc in Content Export YAML 8
File
drush/content_export_yaml.batch.inc
View source
<?php
use Drupal\content_export_yaml\ContentExport;
function content_export_yaml_import_entity_batch_process($info, $context) {
try {
$export = new ContentExport();
$status = $export
->import($info['id'], $info['entity']);
if ($status) {
drush_print('Success import id = ' . $info['index']);
}
} catch (\Exception $e) {
$message = "Item :" . $info['index'] . " Error: " . $e
->getMessage();
\Drupal::logger("content_export_yaml")
->error($message);
}
}
function content_export_yaml_export_entity_batch_process($info, $context) {
try {
$export = new ContentExport();
$status = $export
->export($info['id'], $info['entity']);
if ($status) {
drush_print('Success exported id = ' . $info['index']);
}
} catch (\Exception $e) {
if (is_object($info['id'])) {
$info['id'] = $info['id']
->id();
}
$message = "Item :" . $info['id'] . " Error: " . $e
->getMessage();
\Drupal::logger("content_export_yaml")
->error($message);
}
}
function content_export_yaml_index_batch_process($info, $context) {
try {
$export = new ContentExport();
$status = $export
->export($info['id'], 'node');
if ($status) {
drush_print('Success exported id = ' . $info['id']);
}
} catch (\Exception $e) {
$message = "Item :" . $info['index'] . " Error: " . $e
->getMessage();
\Drupal::logger("content_export_yaml")
->error($message);
}
}
function content_export_yaml_import_index_batch_process($info, $context) {
try {
$export = new ContentExport();
$status = $export
->importEntity($info['id'], 'node');
if ($status) {
drush_print('Success imported id = ' . $info['index']);
}
} catch (\Exception $e) {
$message = "Item :" . $info['index'] . " Error: " . $e
->getMessage();
\Drupal::logger("content_export")
->error($message);
}
}
function content_export_yaml_block_cim_index_batch_process($info, $context) {
try {
$export = new ContentExport();
$status = $export
->import($info['id'], 'block_content', $info['type']);
if ($status) {
drush_print('Success imported id = ' . $info['index']);
}
} catch (\Exception $e) {
$message = "Item :" . $info['index'] . " Error: " . $e
->getMessage();
\Drupal::logger("content_export")
->error($message);
}
}
function content_export_yaml_block_index_batch_process($info, $context) {
try {
$export = new ContentExport();
$status = $export
->export($info['id'], 'block_content', $info['type']);
if ($status) {
drush_print('Success exported id = ' . $info['index']);
}
} catch (\Exception $e) {
$message = "Item :" . $info['index'] . " Error: " . $e
->getMessage();
\Drupal::logger("content_export_yaml")
->error($message);
}
}
function content_export_yaml_cex_index_batch_process($info, $context) {
try {
$export = new ContentExport();
$status = $export
->export($info['id'], $info['entity'], $info['type']);
if ($status) {
drush_print('Success exported id = ' . $info['index']);
}
} catch (\Exception $e) {
$message = "Item :" . $info['id'] . " Error: " . $e
->getMessage();
\Drupal::logger("content_export_yaml")
->error($message);
}
}
function content_export_yaml_cim_index_batch_process($info, $context) {
try {
$export = new ContentExport();
$status = $export
->importEntity($info['id'], $info['entity']);
if ($status) {
drush_print('Success imported num = ' . $info['index']);
}
} catch (\Exception $e) {
$message = "Item number :" . $info['index'] . " Error: " . $e
->getMessage();
\Drupal::logger("content_export")
->error($message);
}
}