public static function ConvertNodes::convertFieldTables in Convert Nodes 8
File
- src/
ConvertNodes.php, line 198
Class
- ConvertNodes
- ConvertNodes.
Namespace
Drupal\convert_nodesCode
public static function convertFieldTables($field_table_names, $nids, $to_type, $update_fields, &$context) {
$message = 'Converting Field Tables...';
$results = [];
$db = Database::getConnection();
// Field tables have 'entity_id' and 'bundle' columns.
foreach ($field_table_names as $field_name => $table_name) {
// Only do this when from and to fields are the same.
if (in_array(str_replace('_revision', '', $field_name), $update_fields)) {
$results[] = $db
->update($table_name)
->fields([
'bundle' => $to_type,
])
->condition('entity_id', $nids, 'IN')
->execute();
}
}
$context['message'] = $message;
$context['results'] = $results;
}