You are here

library.install in Library 8

Contains library.install.

File

library.install
View source
<?php

/**
 * @file
 * Contains library.install.
 */

/**
 * Migrate data its own field type.
 */
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();
    }
  }
}

Functions

Namesort descending Description
library_update_8001 Migrate data its own field type.