You are here

function field_patterns_export_all_ins in Patterns 7.2

Same name and namespace in other branches
  1. 7 patterns_components/components/field.inc \field_patterns_export_all_ins()
1 string reference to 'field_patterns_export_all_ins'
field_patterns in patterns_components/components/field.inc
@file Patterns component for Fields.

File

patterns_components/components/field.inc, line 37
Patterns component for Fields.

Code

function field_patterns_export_all_ins($args = NULL, &$result = NULL) {

  //$info = field_patterns();
  _field_info_collate_fields(true);
  _field_info_collate_types(true);

  // $form_id = current($info['instance'][PATTERNS_MODIFY]);
  $instances = field_read_instances();
  $result = array();
  switch ($args['type']) {
    case PATTERNS_CREATE:
      foreach ($instances as $voc) {
        $field = (array) field_info_instance($voc['entity_type'], $voc['field_name'], $voc['bundle']);
        $data = array(
          'tag' => 'instance',
        );
        $data['field_name'] = $voc['field_name'];
        $data['entity_type'] = $voc['entity_type'];
        $data['bundle'] = $voc['bundle'];
        $data['label'] = $voc['label'];
        $data['description'] = $voc['description'];
        $data['settings'] = $voc['settings'];
        $data['widget'] = $voc['widget'];
        $data['display'] = $voc['display'];
        $data['required'] = $voc['required'];
        $action = array(
          PATTERNS_CREATE => $data,
        );
        array_push($result, $action);
      }
      break;
    case PATTERNS_MODIFY:
      foreach ($instances as $voc) {
        $field = (array) field_info_instance($voc['entity_type'], $voc['field_name'], $voc['bundle']);
        $data = array(
          'tag' => 'instance',
        );
        $data['field_name'] = $voc['field_name'];
        $data['entity_type'] = $voc['entity_type'];
        $data['bundle'] = $voc['bundle'];
        $data['label'] = $voc['label'];
        $data['description'] = $voc['description'];
        $data['settings'] = $voc['settings'];
        $data['widget'] = $voc['widget'];
        $data['display'] = $voc['display'];
        $data['required'] = $voc['required'];

        //$data = array_merge($data, $field);
        $action = array(
          PATTERNS_MODIFY => $data,
        );
        array_push($result, $action);
      }
      break;
  }
  return $result;
}