public function ContentEntity::fields in Drupal 8
Same name and namespace in other branches
- 9 core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php \Drupal\migrate_drupal\Plugin\migrate\source\ContentEntity::fields()
Returns available fields on the source.
Return value
array Available fields in the source, keys are the field machine names as used in field mappings, values are descriptions.
Overrides MigrateSourceInterface::fields
File
- core/
modules/ migrate_drupal/ src/ Plugin/ migrate/ source/ ContentEntity.php, line 257
Class
- ContentEntity
- Source plugin to get content entities from the current version of Drupal.
Namespace
Drupal\migrate_drupal\Plugin\migrate\sourceCode
public function fields() {
// Retrieving fields from a non-fieldable content entity will throw a
// LogicException. Return an empty list of fields instead.
if (!$this->entityType
->entityClassImplements('Drupal\\Core\\Entity\\FieldableEntityInterface')) {
return [];
}
$field_definitions = $this->entityFieldManager
->getBaseFieldDefinitions($this->entityType
->id());
if (!empty($this->configuration['bundle'])) {
$field_definitions += $this->entityFieldManager
->getFieldDefinitions($this->entityType
->id(), $this->configuration['bundle']);
}
$fields = array_map(function ($definition) {
return (string) $definition
->getLabel();
}, $field_definitions);
return $fields;
}