You are here

function pmpapi_get_augmented_instances in Public Media Platform API Integration 7

Generate a list of instances (including label as a fake instance) 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 instance info (including label as fake instance, if applicable)

1 call to pmpapi_get_augmented_instances()
pmpapi_pull_admin_config in pmpapi_pull/pmpapi_pull.admin.inc
Form constructor for the PMPAPI pull admin form.

File

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

Code

function pmpapi_get_augmented_instances($entity_type, $bundle_name) {
  $instances = field_info_instances($entity_type, $bundle_name);
  $entity_info = entity_get_info($entity_type);
  if (!empty($entity_info['entity keys']['label'])) {
    $label = $entity_info['entity keys']['label'];
    $fake_instance = array(
      'label' => $label,
      'field_name' => $label,
      'widget' => array(
        'type' => 'text_textfield',
      ),
    );
    $instances = array_merge(array(
      $label => $fake_instance,
    ), $instances);
  }
  return $instances;
}