function library_update_8001 in Library 8
Migrate data its own field type.
File
- ./
library.install, line 11 - Contains library.install.
Code
function library_update_8001() {
$config = \Drupal::configFactory()
->getEditable('field.storage.node.library_item');
$config
->set('type', 'library_item_field_type');
$config
->set('settings', [
'target_type' => 'library_item',
]);
$config
->set('module', 'library');
$config
->save();
$map = \Drupal::service('entity_field.manager')
->getFieldMap()['node'];
if (isset($map['library_item'])) {
foreach ($map['library_item']['bundles'] as $key => $bundle) {
$item = \Drupal::configFactory()
->getEditable('field.field.node.' . $key . '.library_item');
$item
->set('field_type', 'library_item_field_type');
$item
->set('module', 'library');
$item
->save();
}
}
}