You are here

public function Individual::label in CRM Core 8.3

Same name and namespace in other branches
  1. 8 modules/crm_core_contact/src/Entity/Individual.php \Drupal\crm_core_contact\Entity\Individual::label()
  2. 8.2 modules/crm_core_contact/src/Entity/Individual.php \Drupal\crm_core_contact\Entity\Individual::label()

Gets the label of the entity.

Return value

string|null The label of the entity, or NULL if there is no label defined.

Overrides EntityInterface::label

File

modules/crm_core_contact/src/Entity/Individual.php, line 174

Class

Individual
CRM Individual Entity Class.

Namespace

Drupal\crm_core_contact\Entity

Code

public function label() {
  $label = '';
  if ($item = $this
    ->get('name')
    ->first()) {
    $label = "{$item->given} {$item->family}";
  }
  if (empty(trim($label))) {
    $label = $this
      ->t('Nameless #@id', [
      '@id' => $this
        ->id(),
    ]);
  }
  \Drupal::moduleHandler()
    ->alter('crm_core_individual_label', $label, $this);
  return $label;
}