How to get field mapping information in custom module? I am trying to call field_info_field_map() in my DefaultForm.php . What is the right way? I am getting the following error: 


  Error: Class 'Drupal\module_name\Form\Field' not found in
  Drupal\module_name\Form\DefaultForm->module_name_settings_get_field_options()


The code I am using is as follow:

$fields = Field::fieldInfo()-&gt;getFieldMap();


the code i am trying to convert to d8

function mn_settings_get_field_options() {
  static $options = null;
  if (is_array($options)) {
    return $options;
  }
  $options = array();
  $fields = field_info_field_map();
  foreach ($fields as $field_name =&gt; $field_data) {
    if (isset($field_data['bundles']['node'])) {
      $node_types = $field_data['bundles']['node'];
      $options[$field_name] = $field_name . ' (In content types: ' . implode(', ', $node_types) . ')';
    }
  }
  asort($options);
  return $options;
}
Looks one potential solution is to use is EntityFieldManager::getFieldMap. See the change log for this change.

Also, FYI:


  When working directly with an $entity, the field definitions (which include base and configurable fields) can be directly requested from the object with $entity->getFieldDefinitions() or $entity->getFieldDefinition($field_name)