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 220
Field API's drush integration

Code

function drush_field_info($type = NULL) {
  if (is_null($type)) {
    $type = drush_choice(drupal_map_assoc(array('types', 'fields')), dt('Which information do you wish to see?'));
  }

  switch ($type) {
    case 'fields':
      $rows[] = array(
        dt('Field name'),
        dt('Field type'),
        dt('Bundles'),
      );
      $info = field_info_fields();
      foreach ($info as $field_name => $field) {
        $bundle_strs = array();
        foreach ($field['bundles'] as $entity_type => $bundles) {
          $bundle_strs[] = implode(',', $bundles);
        }
        $row = array(
          $field_name,
          $field['type'],
          implode(' ', $bundle_strs),
        );
        $rows[] = $row;
        $pipe[] = implode(',', $row);
      }
      break;
    case 'types':
      $rows[] = array(
        dt('Field type'),
        dt('Default widget'),
        dt('Widgets'),
      );
      $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);
        $row = array(
          $type_name,
          $type['default_widget'],
          implode(', ', array_keys($widgets)),
        );
        $rows[] = $row;
        $pipe[] = implode(',', $row);
      }
      break;
  }

  drush_print_table($rows, TRUE);
  drush_print_pipe($pipe);
  return $rows;
}