You are here

function gathercontent_ui_import_finished in GatherContent 8.5

Finished callback.

1 string reference to 'gathercontent_ui_import_finished'
ContentImportSelectForm::submitForm in gathercontent_ui/src/Form/ContentImportSelectForm.php
Form submission handler.

File

gathercontent_ui/gathercontent_ui.module, line 42
GatherContent UI.

Code

function gathercontent_ui_import_finished($success, $results, $operations) {
  $messenger = \Drupal::messenger();
  if ($success) {
    if ($results['success'] > 0) {
      $messenger
        ->addStatus(\Drupal::translation()
        ->formatPlural($results['success'], '1 item was imported successfully.', '@count items were imported successfully.'));
    }
    if ($results['failed'] > 0) {
      $messenger
        ->addError(\Drupal::translation()
        ->formatPlural($results['failed'], '1 item was not imported. Check errors below.', '@count items were not imported. Check errors below.'));
    }
    if ($results['failed'] == 0 && $results['success'] == 0) {
      $messenger
        ->addStatus(t('Nothing was imported or updated.'));
    }
    if (isset($results['messages']) && count($results['messages']) > 0) {
      foreach ($results['messages'] as $message) {
        $messenger
          ->addError($message);
      }
    }
  }
  else {
    $error_operation = reset($operations);
    $messenger
      ->addError(t('An error occurred while processing @operation with arguments : @args', [
      '@operation' => $error_operation[0],
      '@args' => print_r($error_operation[0], TRUE),
    ]));
  }
  return new RedirectResponse(Url::fromRoute('gathercontent_ui.tracked_entities_list')
    ->toString());
}