You are here

function pmpapi_get_augmented_fields in Public Media Platform API Integration 7

Generate a list of fields (including label as a fake field) for a given bundle.

Parameters

string $entity_type: Name of an entity type

string $bundle_name: Name of an entity bundle

Return value

array A list of field info (including lable as fake field, if applicable)

4 calls to pmpapi_get_augmented_fields()
pmpapi_pull_admin_config_validate in pmpapi_pull/pmpapi_pull.admin.inc
Form validation handler for pmpapi_pull_admin_config().
pmpapi_push_admin_config in pmpapi_push/pmpapi_push.admin.inc
Form constructor for the PMPAPI push admin form.
pmpapi_push_admin_config_submit in pmpapi_push/pmpapi_push.admin.inc
Form submission handler for pmpapi_push_admin_config().
pmpapi_push_admin_config_validate in pmpapi_push/pmpapi_push.admin.inc
Form validation handler for pmpapi_push_admin_config().

File

./pmpapi.module, line 561
Creates basic calls to the PMP API.

Code

function pmpapi_get_augmented_fields($entity_type, $bundle_name) {
  $instances = field_info_instances($entity_type, $bundle_name);
  $fields = array();
  foreach ($instances as $instance) {
    $name = $instance['field_name'];
    $fields[$name] = field_info_field($name);
    $fields[$name]['instance'] = $instance;
  }
  $entity_info = entity_get_info($entity_type);
  if (!empty($entity_info['entity keys']['label'])) {
    $label = $entity_info['entity keys']['label'];
    $fake_field = array(
      'label' => $label,
      'field_name' => $label,
      'type' => 'text',
      'instance' => array(
        'required' => TRUE,
      ),
    );
    $fields = array_merge(array(
      $label => $fake_field,
    ), $fields);
  }
  return $fields;
}