You are here

function drush_services_client_entity_mapping in Services Client 7

Create mapping for entity

Parameters

$entity_type:

$entity_bundle:

File

./services_client.drush.inc, line 78
Services client drush integration

Code

function drush_services_client_entity_mapping($entity_type, $entity_bundle) {
  $mirror = drush_get_option('mirror', FALSE);
  $language = drush_get_option('language', 'und');
  $properties = entity_get_property_info($entity_type);
  $bundle_fields = array_keys($properties['bundles'][$entity_bundle]['properties']);
  $all_fields = field_info_fields();
  $fields = array();
  foreach ($bundle_fields as $field_name) {
    $fields[$field_name] = $all_fields[$field_name];
  }
  $properties = array_keys($properties['properties']);
  $output = array();
  foreach ($properties as $property) {
    if ($mirror) {
      $property = "{$property}|{$property}";
    }
    $output[] = $property;
  }
  foreach ($fields as $field_name => $field) {
    foreach ($field['columns'] as $column_name => $info) {
      $line = implode(SERVICES_CLIENT_DELMITER_ARRAY, array(
        $field_name,
        $language,
        0,
        $column_name,
      ));
      if ($mirror) {
        $line = "{$line}|{$line}";
      }
      $output[] = $line;
    }
  }
  drush_print(implode("\n", $output));
}