public static function ConvertBundles::convertBaseTables in Convert Bundles 8
File
- src/
ConvertBundles.php, line 182
Class
- ConvertBundles
- ConvertBundles.
Namespace
Drupal\convert_bundlesCode
public static function convertBaseTables($entity_type, $base_table_names, $ids, $to_type, &$context) {
$message = 'Converting Base Tables...';
$results = [];
$db = Database::getConnection();
// Base tables have 'nid' and 'type' columns.
$definition = \Drupal::entityTypeManager()
->getDefinition($entity_type);
$id = $definition
->getKey('id');
$type = $definition
->getKey('bundle');
foreach ($base_table_names as $table_name) {
$results[] = $db
->update($table_name)
->fields([
$type => $to_type,
])
->condition($id, $ids, 'IN')
->execute();
}
$context['message'] = $message;
$context['results'] = $results;
}