You are here

protected function FieldableEntity::getFields in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldableEntity.php \Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity::getFields()
  2. 10 core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldableEntity.php \Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity::getFields()

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.

8 calls to FieldableEntity::getFields()
Comment::prepareRow in core/modules/comment/src/Plugin/migrate/source/d7/Comment.php
Adds additional data to the row.
CommentEntityTranslation::prepareRow in core/modules/comment/src/Plugin/migrate/source/d7/CommentEntityTranslation.php
Adds additional data to the row.
Node::prepareRow in core/modules/node/src/Plugin/migrate/source/d7/Node.php
Adds additional data to the row.
NodeEntityTranslation::prepareRow in core/modules/node/src/Plugin/migrate/source/d7/NodeEntityTranslation.php
Adds additional data to the row.
Term::prepareRow in core/modules/taxonomy/src/Plugin/migrate/source/d7/Term.php
Adds additional data to the row.

... See full list

File

core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldableEntity.php, line 24

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) {
  $query = $this
    ->select('field_config_instance', 'fci')
    ->fields('fci')
    ->condition('fci.entity_type', $entity_type)
    ->condition('fci.bundle', isset($bundle) ? $bundle : $entity_type)
    ->condition('fci.deleted', 0);

  // Join the 'field_config' table and add the 'translatable' setting to the
  // query.
  $query
    ->leftJoin('field_config', 'fc', 'fci.field_id = fc.id');
  $query
    ->addField('fc', 'translatable');
  return $query
    ->execute()
    ->fetchAllAssoc('field_name');
}