You are here

public static function ConvertBundles::getFieldTableNames in Convert Bundles 8

1 call to ConvertBundles::getFieldTableNames()
ConvertBundlesForm::convertBundles in src/Form/ConvertBundlesForm.php

File

src/ConvertBundles.php, line 160

Class

ConvertBundles
ConvertBundles.

Namespace

Drupal\convert_bundles

Code

public static function getFieldTableNames($entity_type, $fields_from) {
  $table_mapping = \Drupal::service('entity_type.manager')
    ->getStorage($entity_type)
    ->getTableMapping();
  $field_table_names = [];
  foreach ($fields_from as $field_key) {
    foreach ($field_key as $field) {
      if ($field
        ->getFieldStorageDefinition()
        ->isBaseField() == FALSE) {
        $field_name = $field
          ->getName();
        $field_table = $table_mapping
          ->getFieldTableName($field_name);
        $field_table_names[$field_name] = $field_table;
        $field_storage_definition = $field
          ->getFieldStorageDefinition();
        $field_revision_table = $table_mapping
          ->getDedicatedRevisionTableName($field_storage_definition);

        // Field revision tables DO have the bundle!
        $field_table_names[$field_name . '_revision'] = $field_revision_table;
      }
    }
  }
  return $field_table_names;
}