You are here

function get_fields in Content Import 8.9

To get all Content Type Fields.

2 calls to get_fields()
ContentImport::contentImportcallback in src/Form/ContentImport.php
Content Import Sample CSV Creation.
import_node in ./contentimport.module
To import data as Content type nodes.

File

./contentimport.module, line 30
Module file for Contentimport.

Code

function get_fields($content_type) {
  $fields = [];
  foreach (\Drupal::service('entity_field.manager')
    ->getFieldDefinitions('node', $content_type) as $field_definition) {
    if (!empty($field_definition
      ->getTargetBundle())) {
      $fields['name'][] = $field_definition
        ->getName();
      $fields['type'][] = $field_definition
        ->getType();
      $fields['setting'][] = $field_definition
        ->getSettings();
    }
  }
  return $fields;
}