You are here

function field_base_features_export_render in Features 7.2

Implements hook_features_export_render().

File

includes/features.field.inc, line 158
Features integration on behalf of 'field' module.

Code

function field_base_features_export_render($module, $data, $export = NULL) {
  $translatables = $code = array();
  $code[] = '  $field_bases = array();';
  $code[] = '';
  foreach ($data as $identifier) {
    if ($field = features_field_base_load($identifier)) {
      unset($field['columns']);
      unset($field['foreign keys']);

      // Only remove the 'storage' declaration if the field is using the default
      // storage type.
      if ($field['storage']['type'] == variable_get('field_storage_default', 'field_sql_storage')) {
        unset($field['storage']);
      }

      // If we still have a storage declaration here it means that a non-default
      // storage type was altered into to the field definition. And no one would
      // never need to change the 'details' key, so don't render it.
      if (isset($field['storage']['details'])) {
        unset($field['storage']['details']);
      }
      _field_instance_features_export_sort($field);
      $field_export = features_var_export($field, '  ');
      $field_prefix = '  // Exported field_base: ';
      $field_identifier = features_var_export($identifier);
      if (features_field_export_needs_wrap($field_prefix, $field_identifier)) {
        $code[] = rtrim($field_prefix);
        $code[] = "  // {$field_identifier}.";
      }
      else {
        $code[] = $field_prefix . $field_identifier . '.';
      }
      $code[] = "  \$field_bases[{$field_identifier}] = {$field_export};";
      $code[] = "";
    }
  }
  $code[] = '  return $field_bases;';
  $code = implode("\n", $code);
  return array(
    'field_default_field_bases' => $code,
  );
}