protected function FieldableEntity::getFields in Drupal 10
Same name and namespace in other branches
- 8 core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldableEntity.php \Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity::getFields()
- 9 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 39
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\d7Code
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', $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');
}