function gathercontent_import_process in GatherContent 8.4
Same name and namespace in other branches
- 8.5 gathercontent.module \gathercontent_import_process()
- 8.3 gathercontent.module \gathercontent_import_process()
- 7.3 gathercontent.import.inc \gathercontent_import_process()
Batch operation callback for importing items.
3 string references to 'gathercontent_import_process'
- ContentImportSelectForm::submitForm in gathercontent_ui/
src/ Form/ ContentImportSelectForm.php - Form submission handler.
- ContentUpdateConfirmForm::submitForm in gathercontent_ui/
src/ Form/ ContentUpdateConfirmForm.php - Form submission handler.
- drush_gathercontent_import in ./
gathercontent.drush.inc - Implements drush_COMMAND().
File
- ./
gathercontent.module, line 48 - Main module file for GatherContent module.
Code
function gathercontent_import_process($gc_id, ImportOptions $import_options, &$context = []) {
/** @var \Drupal\gathercontent\Import\Importer $importer */
$importer = \Drupal::service('gathercontent.importer');
$client = $importer
->getClient();
/** @var \Cheppers\GatherContent\DataTypes\Item $item */
$item = $client
->itemGet($gc_id);
/** @var \Cheppers\GatherContent\DataTypes\Template $template */
$template = $client
->templateGet($item->templateId);
$operation_item = \Drupal::entityTypeManager()
->getStorage('gathercontent_operation_item')
->create([
'operation_uuid' => $import_options
->getOperationUuid(),
'item_status' => $item->status->name,
'item_status_color' => $item->status->color,
'template_name' => $template->name,
'item_name' => $item->name,
'gc_id' => $gc_id,
]);
try {
$nid = $importer
->import($item, $import_options);
$operation_item->nid = $nid;
$operation_item->status = 'Success';
$operation_item
->save();
} catch (\Exception $e) {
$operation_item->status = $e
->getMessage();
$operation_item
->save();
}
$context['results']['uuid'] = $import_options
->getOperationUuid();
}