You are here

function _civicrm_entity_get_title in CiviCRM Entity 7

Same name and namespace in other branches
  1. 7.2 civicrm_entity.module \_civicrm_entity_get_title()
2 calls to _civicrm_entity_get_title()
civicrm_entity_get_schema in ./civicrm_entity.module
Get schema for entities.
_civicrm_entity_getproperties in ./civicrm_entity.module
Calculate fields for entities

File

./civicrm_entity.module, line 361
Implement CiviCRM entities as a Drupal Entity.

Code

function _civicrm_entity_get_title($field_specs, $entity_type = '') {
  if (!empty($entity_type)) {
    $label_field = _civicrm_entity_labels($entity_type);
  }
  else {
    $label_field = 'title';
  }
  if (empty($field_specs[$label_field])) {
    if (array_key_exists('label', $field_specs)) {
      $label_field = 'label';
    }
    else {
      if (array_key_exists('name', $field_specs)) {
        $label_field = 'name';
      }
    }
  }
  $title = empty($field_specs[$label_field]) ? 'Title not defined in schema' : $field_specs[$label_field];
  return $title;
}