You are here

function party_get_entity_data_set in Party 7

Same name and namespace in other branches
  1. 8.2 party.module \party_get_entity_data_set()

Get the data set definition associated with a given entity and bundle.

Parameters

$entity_type: The entity type e.g profile2 etc.

$entity: The entity object or id.

Return value

A data set name if one exists, NULL otherwise.

1 call to party_get_entity_data_set()
party_preprocess_entity in ./party.module
Implements hook_preprocess_HOOK().

File

./party.module, line 641
Provides a generic CRM party entity.

Code

function party_get_entity_data_set($entity_type, $entity) {
  $data_set_info = party_get_data_set_info();

  // Get bundle.
  $info = entity_get_info($entity_type);
  $bundle_key = empty($info['entity keys']['bundle']) ? FALSE : $info['entity keys']['bundle'];
  if (!$bundle_key) {
    $bundle = $entity_type;
  }
  else {
    $bundle = $entity->{$bundle_key};
  }
  foreach ($data_set_info as $data_set_name => $data_set) {
    if ($data_set['entity type'] == $entity_type && (!isset($data_set['entity bundle']) || $data_set['entity bundle'] == $bundle)) {
      return $data_set_name;
    }
  }
  return NULL;
}