You are here

public static function NodeImportController::addFailedRecordsInRc in Simple Node Importer 8

Add data to node resolution table.

2 calls to NodeImportController::addFailedRecordsInRc()
NodeImportController::nodeImportBatchFinished in src/Controller/NodeImportController.php
Callback : Called when batch process is finished.
UserImportController::userImportBatchFinished in src/Controller/UserImportController.php
Callback : Called when batch process is finished.

File

src/Controller/NodeImportController.php, line 178

Class

NodeImportController
Default controller for the simple_node_importer module.

Namespace

Drupal\simple_node_importer\Controller

Code

public static function addFailedRecordsInRc($result) {
  if (isset($result['data']) && !empty($result['data'])) {
    $import_status = [
      'success' => !empty($result['created']) ? $result['created'] : "",
      'fail' => !empty($result['failed']) ? $result['failed'] : "",
    ];
    $sni_nid = !empty($result['sni_nid']) ? $result['sni_nid'] : NULL;
    foreach ($result['data'] as $data) {
      $conn = Database::getConnection();
      $resolution_log = $conn
        ->insert('node_resolution')
        ->fields([
        'sni_nid' => $sni_nid,
        'data' => $data,
        'reference' => \Drupal::service('snp.get_services')
          ->generateReference(10),
        'status' => serialize($import_status),
        'created' => REQUEST_TIME,
      ])
        ->execute();
    }
    if ($resolution_log) {
      drupal_set_message(t('Failed records added to resolution center.'));
    }
  }
}