function FieldableEntity::getFields
Same name in other branches
- 9 core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldableEntity.php \Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity::getFields()
- 8.9.x core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldableEntity.php \Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity::getFields()
- 11.x 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.
Typically, getFields() is used in the prepareRow method of a source plugin to get a list of all the field instances of the entity. A source plugin can then loop through the list of fields to do any other preparation before processing the row. Typically, a source plugin will use getFieldValues() to get the values of each field.
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.
File
-
core/
modules/ migrate_drupal/ src/ Plugin/ migrate/ source/ d7/ FieldableEntity.php, line 47
Class
- FieldableEntity
- Base class for D7 source plugins which need to collect field values.
Namespace
Drupal\migrate_drupal\Plugin\migrate\source\d7Code
protected function getFields($entity_type, $bundle = NULL) {
$cid = $entity_type . ':' . ($bundle ?? '');
if (!isset($this->fieldInfo[$cid])) {
$query = $this->select('field_config_instance', 'fci')
->fields('fci')
->condition('fci.entity_type', $entity_type)
->condition('fci.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');
$this->fieldInfo[$cid] = $query->execute()
->fetchAllAssoc('field_name');
}
return $this->fieldInfo[$cid];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.