function drush_field_info

8.0.x field.drush.inc drush_field_info($type = NULL)
6.x field.drush.inc drush_field_info($type = NULL)
7.x field.drush.inc drush_field_info($type = NULL)
4.x field.drush.inc drush_field_info($type = NULL)
5.x field.drush.inc drush_field_info($type = NULL)

File

commands/core/field.drush.inc, line 286
Field API's drush integration

Code

function drush_field_info($type = NULL) {
  if (!isset($type)) {
    // Don't ask in 'pipe' mode -- just default to 'fields'.
    if (drush_get_context('DRUSH_PIPE')) {
      $type = 'fields';
    }
    else {
      $type = drush_choice(drupal_map_assoc(array('types', 'fields')), dt('Which information do you wish to see?'));
    }
  }

  $result = array();
  switch ($type) {
    case 'fields':
      drush_hide_output_fields(array('type-name', 'widget', 'widgets'));
      $info = field_info_fields();
      foreach ($info as $field_name => $field) {
        $bundle_strs = array();
        foreach ($field['bundles'] as $entity_type => $bundles) {
          $bundle_strs += $bundles;
        }
        $result[$field_name] = array(
          'field-name' => $field_name,
          'type' => $field['type'],
          'bundle' => $bundle_strs,
        );
      }
      break;
    case 'types':
      drush_hide_output_fields(array('field-name', 'type', 'bundle'));
      $info = field_info_field_types();
      module_load_include('inc', 'field_ui', 'field_ui.admin');
      $widgets = field_info_widget_types();
      foreach ($info as $type_name => $type) {
        $widgets = field_ui_widget_type_options($type_name);
        $result[$type_name] = array(
          'type-name' => $type_name,
          'widget' => $type['default_widget'],
          'widgets' => $widgets,
        );
      }
      break;
    default:
      return drush_set_error('DRUSH_FIELD_INVALID_SELECTION', dt("Argument for drush field-info must be 'fields' or 'types'"));
  }

  return $result;
}