You are here

function content_features_export_render in Features 6

Implementation of hook_features_export_render().

File

includes/features.content.inc, line 100

Code

function content_features_export_render($module, $data) {
  $translatables = $code = array();
  $code[] = '  $fields = array();';
  $code[] = '';
  foreach ($data as $instance) {
    $instance = explode('-', $instance);
    $type_name = $instance[0];
    $field_name = $instance[1];
    if ($field = content_fields($field_name, $type_name)) {
      unset($field['columns']);
      unset($field['locked']);
      unset($field['db_storage']);
      $field_identifier = features_var_export(content_features_identifier($field));
      $field_export = features_var_export($field, '  ');
      $code[] = "  // Exported field: {$field_name}";
      $code[] = "  \$fields[{$field_identifier}] = {$field_export};";
      $code[] = "";

      // Add any labels to translatables array.
      if (!empty($field['widget']['label'])) {
        $translatables[] = $field['widget']['label'];
      }

      // Add any descriptions to translatables array.
      if (!empty($field['widget']['description'])) {
        $translatables[] = $field['widget']['description'];
      }
    }
  }
  if (!empty($translatables)) {
    $code[] = features_translatables_export($translatables, '  ');
  }
  $code[] = '  return $fields;';
  $code = implode("\n", $code);
  return array(
    'content_default_fields' => $code,
  );
}