In Drupal 8 there are two types of fields: "base fields" like node.uid, and user-defined fields like 'node.body'.
All of the field names for one entity type can be found with EntityFieldManagerInterface->getFieldMap()
. However this only contains the field type (as string) and a list of bundles.
For the base fields like 'uid', there is EntityFieldManagerInterface->getbaseFieldDefinitions($entity_type_id)
. But this omits the user-defined fields.
For user-defined fields, there is EntityTypeManagerInterface->getStorage('field_storage_config')->load($entity_type_id . $field_name);
. But this does not include base fields like 'node.uid'.
There is also EntityFieldManagerInterface->getFieldDefinitions($entity_type_id, $bundle_name)
. But this has to be called per bundle.
There is more in FieldTypePluginmanager, EntityAdapter, and EntityDataDefinition. The more I look, the more confusing and complex this entire architecture looks to me..
Background
I would like to show a select element where a user can choose a field. Entity type is given, but bundle is not. Options are filtered by various criteria. E.g. maybe I want to show all fields where the item type extends EntityReferenceItem, and the reference target type is 'node'. For this I need to inspect the definition of each field.
All of this is for D8 version of https://drupal.org/project/renderkit.