Skip to content

Instantly share code, notes, and snippets.

@politsin
Last active October 18, 2018 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save politsin/1c3d55b25196b327762391fda75c9be5 to your computer and use it in GitHub Desktop.
Save politsin/1c3d55b25196b327762391fda75c9be5 to your computer and use it in GitHub Desktop.
<?php
namespace Drupal\migration\Utility;
/**
* FeedsToMigration.
*/
class InsertMigration {
/**
* Insert.
*/
public static function insert($data, $table = 'migrate_map_********') {
$db = \Drupal::database();
$fields = [
'source_ids_hash',
'sourceid1',
'destid1',
'source_row_status',
'rollback_action',
'last_imported',
'hash',
];
foreach ($data as $src => $dst) {
print "{$src} > {$dst}\n";
$hash = hash('sha256', serialize(array_map('strval', [$src])));
$line = [$hash, $src, $dst, 0, 0, 0, ""];
// Insert the record to table.
$insert = $db->insert($table)->fields($fields)->values($line);
// $insert->execute();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment