8.5.x FieldableEntity.php FieldableEntity::getFields($entity_type, $bundle = NULL)
8.0.x FieldableEntity.php FieldableEntity::getFields($entity_type, $bundle = NULL)
8.1.x FieldableEntity.php FieldableEntity::getFields($entity_type, $bundle = NULL)
8.2.x FieldableEntity.php FieldableEntity::getFields($entity_type, $bundle = NULL)
8.3.x FieldableEntity.php FieldableEntity::getFields($entity_type, $bundle = NULL)
8.4.x FieldableEntity.php FieldableEntity::getFields($entity_type, $bundle = NULL)
8.6.x FieldableEntity.php FieldableEntity::getFields($entity_type, $bundle = NULL)

Returns all non-deleted field instances attached to a specific entity type.

Parameters

string $entity_type: The entity type ID.

string|NULL $bundle: (optional) The bundle.

Return value

array[] The field instances, keyed by field name.

File

core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldableEntity.php, line 29
Contains \Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity.

Class

FieldableEntity
Base class for D7 source plugins which need to collect field values from the Field API.

Namespace

Drupal\migrate_drupal\Plugin\migrate\source\d7

Code

protected function getFields($entity_type, $bundle = NULL) {
  return $this
    ->select('field_config_instance', 'fci')
    ->fields('fci')
    ->condition('entity_type', $entity_type)
    ->condition('bundle', isset($bundle) ? $bundle : $entity_type)
    ->condition('deleted', 0)
    ->execute()
    ->fetchAllAssoc('field_name');
}